Handling Push Notifications when App is NOT running (i.e Totally Killed)

前端 未结 5 1324
孤城傲影
孤城傲影 2021-01-07 07:16

I\'m able to send push notifications to my IOS device. But when I click on that notification it just opens the app. No message is shown inside the app.

Code used by

5条回答
  •  感动是毒
    2021-01-07 07:33

    When application is totally killed get notification code

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    if (launchOptions != nil)
    {
         //opened from a push notification when the app is closed
        NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (userInfo != nil)
        {
             NSLog(@"userInfo->%@",[userInfo objectForKey:@"aps"]);
             //write you push handle code here
    
        }
    
    }
    }
    

    For more go through this link: Handling Push Notifications when App is Terminated

提交回复
热议问题