简体   繁体   English

是否可以检测到推送通知到达?

[英]Is it possible to detect push-notification arrival?

I can catch an event of opening push-notification via 我可以通过以下方式捕获打开推送通知的事件

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

but user may receive push-notification, but doesn't open it. 但是用户可能会收到推送通知,但没有打开它。 So is it possible to handle an arrival of push-notification? 那么有可能处理推送通知的到达吗?

The method you are referring to in your question is called only if a push notification was received while the app was running in the foreground. 仅当应用程序在前台运行时收到推送通知时,才会调用您在问题中所指的方法。 In order to handle push notifications that were used to launch the application (or bring the app back from the background), you need to check the "options" dictionary within your appDelegate's didFinishLaunchingWithOptions method. 为了处理用于启动应用程序(或使应用程序从后台返回)的推送通知,您需要检查appDelegate的didFinishLaunchingWithOptions方法中的“ options”字典。

To answer your additional question - no, if the user didn't open your app with a push notification, there's no way you can gain access to it. 要回答您的其他问题-不,如果用户未通过推送通知打开您的应用,则您无权访问它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM