简体   繁体   English

清除通知后,Apple Push通知信息丢失

[英]Apple push notification info is missing when we clear the notifications

I have received push notification, if i open the push notification then didReceiveRemoteNotification is calling and i am getting the notification information, instead of if i clear the notifications and open the app then didReceiveRemoteNotification is not getting called. 我已经收到推送通知,如果我打开了推送通知,则didReceiveRemoteNotification正在调用,并且我正在获取通知信息,而不是如果我清除通知并打开应用程序,则didReceiveRemoteNotification没有被调用。 How to resolve this? 如何解决呢?

If you open the app from the launch icon (instead of opening it from the push notification), didReceiveRemoteNotification will not be called and you'll have no way to access the notification data. 如果从启动图标打开应用程序(而不是从推送通知中打开应用程序),则不会调用didReceiveRemoteNotification并且您将无法访问通知数据。 It doesn't matter if you clear the notifications or not. 是否清除通知都没有关系。

If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate's application:didFinishLaunchingWithOptions: method (if implemented); 如果点击了操作按钮(在运行iOS的设备上),则系统将启动应用程序,并且该应用程序将调用其委托人的应用程序:didFinishLaunchingWithOptions:方法(如果已实现); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications). 它传入通知有效负载(用于远程通知)或本地通知对象(用于本地通知)。

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification . 如果在运行iOS的设备上点击了应用程序图标,则该应用程序将调用相同的方法,但不提供有关通知的信息

As Eran pointed out, if You're opening the app from the Icon that callback will not be called. 正如Eran所指出的,如果您从Icon打开应用程序,则不会调用回调。 I don't know if the notification is totally removed when You delete it from the notification center list, but if the app is not running and has been launched by tapping on the notification, you can check for the notification in the launchOptions at the startup: 我不知道从通知中心列表中删除通知时是否将通知完全删除,但是如果该应用未运行且已通过点击通知启动,则可以在启动时在launchOptions中检查通知:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
    NSDictionary *notif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
    if (notif) {
       //handle your notification here
    }
    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有 Apple 推送通知服务的推送通知? - Push Notifications without Apple Push Notification Service? Apple Push Notifications-删除徽章但不删除通知文本 - Apple Push Notifications - Remove Badge But Not Notification Text Apple推送通知服务发送重复通知 - Apple Push Notification Service sends repeated notifications 从Apple推送通知反馈中获取信息 - Get info from Apple push notification feedback 苹果推送通知中的文件丢失错误 - File Missing Error on Apple Push Notification 使用 APNs 密钥发送通知时,是否需要 Apple 推送通知服务 SSL 证书? - Is an Apple Push Notification service SSL Certificate necessary when using an APNs key for sending notifications? React Native - 在接收本地推送通知时清除以前的推送通知 - React Native - Clear previous push notifications on receiving local push notification Apple Push Notification — 是否可以批量请求大量通知? - Apple Push Notification — is it possible to make a batch request for a large number of notifications? 选择一个后,清除通知中心的推送通知 - Clear Push notifications from notification centre after selecting one 更新通行证时未收到Apple Push Notification - Apple Push Notification not received when updating a pass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM