Which method will be triggered when the notification received on iPhone(not after the notification is tapped and opened)?

后端 未结 4 1083
遇见更好的自我
遇见更好的自我 2021-01-16 05:41

I’m now using didReceiveRemoteNotification to get the payload of the notification pushed from Parse, however, it is only triggered when the notification is tapp

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 05:50

    You must look for this method in app delegate:-

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

    Now check whether your app has received any push notification/'s or not

    UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (notification) {
            NSLog(@"app received a notification %@",notification);
            [self application:application didReceiveRemoteNotification:(NSDictionary*)notification];
        }else{
            NSLog(@"app did not receive a notification");
        }
    

提交回复
热议问题