[英]Swift: doesn't call didReceiveRemoteNotification()
Here's my sample app 这是我的示例应用
I've had some trouble with this in another app and I'm trying to figure out what I'm doing wrong; 我在另一个应用程序中遇到了一些麻烦,并且试图找出我做错了什么。 It works like this:
它是这样的:
The thing is: even though the didReceiveRemoteNotification()-function should be called, I still get false value when starting the app which shows me, that for any reason this method does not get called. 事实是:即使应调用didReceiveRemoteNotification()函数,启动显示我的应用程序时,我仍然会得到错误的值,无论出于何种原因都不会调用此方法。 Why?
为什么? Can you help me?
你能帮助我吗?
Method didReceiveRemoteNotification()
is not supposed to be called for local notifications... It's only for remote notifications (Push Notifications). 不应为本地通知调用
didReceiveRemoteNotification()
方法……仅用于远程通知(推送通知)。
Use UNUserNotificationCenterDelegate
delegate method 使用
UNUserNotificationCenterDelegate
委托方法
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
See details here https://stackoverflow.com/a/44142742/1825618 在此处查看详细信息https://stackoverflow.com/a/44142742/1825618
Get delivered notifications (Only the ones Currently being displayed in notification center) 获取传递的通知 (仅通知中心中当前显示的通知)
UNUserNotificationCenter.current().getDeliveredNotifications {
(notifications) in
// your code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.