Handling Push Notifications when App is NOT running

后端 未结 8 2188
感动是毒
感动是毒 2020-11-29 16:57

When my App is not running and receives a Push Notification, if I click on that notification, the App is launched - but then it doesn\'t prompt the

8条回答
  •  感情败类
    2020-11-29 17:13

    When your app is not running or killed and you tap on push notification this function will trigger;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    so you should handle it like this,

    UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (localNotif) {
        NSString *json = [localNotif valueForKey:@"data"];
        // Parse your string to dictionary
    }
    

提交回复
热议问题