未調用的RemoteNotification,IOS 10在IOS 9.3中,didReceiveRemoteNotification方法在下列兩種情況下都會被調用。1)當收到推送通知時,2)當用戶通過點擊該通知啟動應用程序時。但在iOS 10上,我注意到didReceiveRemoteNotification方法做不當用戶通過點擊通知啟動應用程序時觸發。只有在收到通知時才調用它。因此,我不能做任何進一步的行動后,應用程序是從通知啟動。解決這個問題的方法應該是什么?知道嗎?
3 回答

夢里花落0921
TA貢獻1772條經驗 獲得超6個贊
SWIFT碼:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. if #available(iOS 10.0, *) { let center = UNUserNotificationCenter.currentNotificationCenter() center.delegate = self } // ... return true}@available(iOS 10.0, *)public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { print(response.notification.request.content.userInfo) }@available(iOS 10.0, *)public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { print(notification.request.content.userInfo)}
- 3 回答
- 0 關注
- 768 瀏覽
添加回答
舉報
0/150
提交
取消