私はアプリのデフォルトの起動をしていますが、ロードするページを識別するペイロードを配信するプッシュ通知によってアプリを開くことが必要な場合もあります。設定プッシュ通知でアプリを開くと、ルートビューコントローラが異なるのですか?
ペイロードロジックはプッシュ通知のdidRecieveレスポンスで処理され、didFinishLaunchingWithOptionsのアプリケーションの起動も処理されます。
どのように私は現在、アプリをクラッシュさせるように見える2つの競合を停止することができます。
基本的には、通知のペイロードに基づいて起動時にルートを変更したいと考えています。現在
私が持っている:また
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
let userInfo = response.notification.request.content.userInfo
// map
let conferenceID = userInfo["cid"] as! String
self.pushNotifiedEventID = conferenceID
self.defaultEvent = conferenceID
if let p = userInfo["p"] as? [String : String] {
let pageID = p["id"]!
let title = p["title"]!
let type = p["type"]!
}
completionHandler()
let hostViewController = HostViewController()
self.window?.rootViewController = hostViewController
}
と:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) {
center.delegate = self
center.requestAuthorization(options: [.badge, .alert , .sound]) { (granted, error) in
if granted {
DispatchQueue.main.async(execute: {
UIApplication.shared.registerForRemoteNotifications()
})
}
}
} else {
let type: UIUserNotificationType = [UIUserNotificationType.badge, UIUserNotificationType.alert, UIUserNotificationType.sound]
let setting = UIUserNotificationSettings(types: type, categories: nil)
UIApplication.shared.registerUserNotificationSettings(setting)
UIApplication.shared.registerForRemoteNotifications()
}
// root VC init + push
window = UIWindow()
let loginViewController = LoginViewController.init(loginView: LoginView(frame: UIScreen.main.bounds))
self.navigationController = UINavigationController(rootViewController: loginViewController)
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
return true
}
私はロジックを取得しますが、私は私がアプリを終了する必要がありますので、私はデバッガに接続されて実行することができませんどのようにクラッシュを診断することができます – jackdm