未调用的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 关注
- 734 浏览
添加回答
举报
0/150
提交
取消