当应用程序首次启动时使用带URL的nsnotification时,特定控制器未打开
问题描述:
当应用程序在通知中包含URL的通知中使用Nsnotification时,无法打开特定控制器。当应用程序首次启动时使用带URL的nsnotification时,特定控制器未打开
当应用程序在后台它工作正常。
答
当应用程序在后台通知被 didReceiveRemoteNotification
第一次启动处理,但是你需要解析的任何通知的launchOptions在didFinishLaunchingWithOptions 喜欢的东西:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if let remoteNotification = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary {
print("we got a notification \(remoteNotification)")
//your logic here (launch controller etc)
}
}