質問するログイン新規登録

質問編集履歴

3

Capabilitiesを含む、現在の状況を追加

2021/04/12 06:27

投稿

abc1222
abc1222

スコア24

title CHANGED
File without changes
body CHANGED
@@ -69,6 +69,11 @@
69
69
 
70
70
  ```
71
71
 
72
+ ### 現状
73
+ CapabilitiesにPush Notificationsを追加済み
74
+ 通知自体は届くが、バナーや通知センターをタップしても画面遷移しない
75
+ ログを見る限り、View3のViewDidloadは動いている様子だが、実機テスト上には表示されていない
76
+
72
77
  ### 構造
73
78
  TabController
74
79
   → NavigationController View1

2

コードの修正

2021/04/12 06:27

投稿

abc1222
abc1222

スコア24

title CHANGED
File without changes
body CHANGED
@@ -55,7 +55,7 @@
55
55
 
56
56
  self.window = UIWindow(frame: UIScreen.main.bounds)
57
57
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
58
- let initialViewController = storyboard.instantiateViewController(withIdentifier: "SearchVC")
58
+ let initialViewController = storyboard.instantiateViewController(withIdentifier: "View3")
59
59
  initialViewController.modalPresentationStyle = .overFullScreen
60
60
  self.window?.rootViewController = initialViewController
61
61
  self.window?.makeKeyAndVisible()

1

AppDelegateを全文記載

2021/04/12 06:21

投稿

abc1222
abc1222

スコア24

title CHANGED
File without changes
body CHANGED
@@ -7,21 +7,66 @@
7
7
 
8
8
 
9
9
  ```Swift
10
+ @main
10
- var window: UIWindow?
11
+ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
11
12
 
13
+ var window: UIWindow?
14
+
15
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
16
+ GMSServices.provideAPIKey("省略")
17
+ FirebaseApp.configure()
18
+
19
+ UNUserNotificationCenter.current().delegate = self
20
+ let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
21
+ UNUserNotificationCenter.current().requestAuthorization(
22
+ options: authOptions,
23
+ completionHandler: {_, _ in })
24
+ application.registerForRemoteNotifications()
25
+
26
+ return true
27
+ }
28
+
29
+ // MARK: UISceneSession Lifecycle
30
+
31
+ func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
32
+
33
+ return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
34
+ }
35
+
36
+ func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
37
+
38
+ }
39
+
12
- func userNotificationCenter(_ center: UNUserNotificationCenter,
40
+ func userNotificationCenter(_ center: UNUserNotificationCenter,
41
+ willPresent notification: UNNotification,
42
+ withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
43
+
44
+ if #available(iOS 14.0, *) {
45
+ completionHandler([[.badge, .banner]])
46
+ } else {
47
+ completionHandler([[.badge, .alert]])
48
+ }
49
+
50
+ }
51
+
52
+ func userNotificationCenter(_ center: UNUserNotificationCenter,
13
53
  didReceive response: UNNotificationResponse,
14
54
  withCompletionHandler completionHandler: @escaping () -> Void) {
15
-
55
+
16
56
  self.window = UIWindow(frame: UIScreen.main.bounds)
17
57
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
18
- let initialViewController = storyboard.instantiateViewController(withIdentifier: "View3")
58
+ let initialViewController = storyboard.instantiateViewController(withIdentifier: "SearchVC")
19
59
  initialViewController.modalPresentationStyle = .overFullScreen
20
60
  self.window?.rootViewController = initialViewController
21
61
  self.window?.makeKeyAndVisible()
62
+
63
+ completionHandler()
64
+
65
+ }
22
66
 
23
- completionHandler()
24
67
  }
68
+
69
+
25
70
  ```
26
71
 
27
72
  ### 構造