How to detect Remote notification in didFinishLaunchingWithOption application method in objective c?

后端 未结 4 1472
予麋鹿
予麋鹿 2021-01-28 22:34

when app in not in background mode ,inactive mode and app is completely closed. than how to detect is their any notification using application\'s delegate \"didFinishLaunchingWi

4条回答
  •  花落未央
    2021-01-28 23:19

    If the App was terminated and is starting again, you can detect the Remote Notification only if the App is being launched because the user tapped on the remote notification in the notifications tray.

    You can detect it in the didFinishLaunchingWithOptions method

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    
      NSDictionary *notificationDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
         if (notificationDict) {
            //Your App received a remote notification
       }else{
            //Your App did not receive a remote notification
       }
    }
    

提交回复
热议问题