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

夢(mèng)里花落0921
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超6個(gè)贊
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 關(guān)注
- 767 瀏覽
添加回答
舉報(bào)
0/150
提交
取消