【发布时间】:2017-05-02 07:46:12
【问题描述】:
我在很多天(超过 20 个帖子)中进行了大量搜索,但没有解决我的问题。
我有一个接收推送通知的应用程序,我可以接收那些远程通知,但是当我点击它时,没有调用委托“didReceiveRemoteNotification”(我想拦截有效负载以执行操作对它的影响)。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("test")
}
提前感谢您的帮助。
didReceiveRemoteNotification 方法不会在用户通过点击通知启动应用程序时触发,而不是在收到通知时触发,永远不会。
对不起,我的英语不好,如果您有任何疑问,请不要犹豫。
【问题讨论】:
-
我已经尝试过这篇文章的解决方案
-
如果您想在通知发送给用户时对其进行处理?使用 UNUserNotificationCenterDelegate 协议方法
-
@Mannopson ,我刚刚添加了:@available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @ escaping (UNNotificationPresentationOptions) -> Void) { print ("test2") } @available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @ escaping () -> Void) { print("test3") } 但没有调用
-
Mannopson 我尝试了您的解决方案,但 willPresent 和 didReceive 代表仍然没有被称为@JigarTarsariya 我看到了这个解决方案但无法测试它,因为它在 Obj C 中,请问我如何在 Swift 3 中做同样的事情?
标签: swift swift3 push-notification ios10 appdelegate