简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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