Push notification data not getting when app launched directly by clicking app icon

后端 未结 4 1404
攒了一身酷
攒了一身酷 2021-02-15 04:09

I have a scenario in which app will get push notification and need to show that messages in home screen of my app, for that i saved the message array into user defaults from my

4条回答
  •  [愿得一人]
    2021-02-15 04:42

    In scenario 1. NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey]; here remoteNotif return nil as you enter into the app through triggering app icon.

    In scenario 2. You can get push notification info through the following method

    -(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    {
          if (userInfo) {
    
              [self handlePushMessage:userInfo];
          }
    }
    

提交回复
热议问题