[英]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.