简体   繁体   中英

Is there any way, get tapped push notification, from notification center? (Push Notification from server)

So, i'm trying to get info from the "push notification" which I tapped from NC. Any ideas how to catch it? I already know that i can get it in method, when it arrives:

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

But it's not enough, let's image we have 5-7 notif's in NC and I tapped specific one... and I need to get all info that inside. The perfect scenario for me: I tapped on push, app opens and shows me data.

I will be glad to any suggestions (also sorry if the question probably already exist, i didn't find it). Thanks!

if the app is fully closed (not in background) and you tap on a notification, the didFinishLaunchingWithOptions method will be called, so add this code

if (launchOptions != nil) {
    NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (dictionary != nil) {

        NSLog(@"Launched from push notification: %@", dictionary);

    }
}

The dictionary is the whole tapped push info

if the app is in background the didReceiveRemoteNotification should be called

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