1

I want to save some push notification data in application.But I can not save data if the user terminate the app by swiping up the app on the multitask viewer (Suspend or not runing state).I used application:didReceiveRemoteNotification:fetchCompletionHandler: to handle it.But still I could not save push notification data

I have set App settings like this

enter image description here

enter image description here

And Payload,

 {
    "aps" : {
       "alert" = "Notification with custom payload",
    },
   "content-available" = 1
 }

And application:didReceiveRemoteNotification:fetchCompletionHandler: looks like this

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    if(application.applicationState == UIApplicationStateInactive) {

        NSLog(@"Inactive");

        //Show the view with the content of the push

        completionHandler(UIBackgroundFetchResultNewData);

    } else if (application.applicationState == UIApplicationStateBackground) {

        NSLog(@"Background");

        NSString *info = [[userInfo valueForKey:@"aps"]valueForKey:@"alert"];

        completionHandler(UIBackgroundFetchResultNewData);

    } else {

        NSLog(@"Active");

        //Show an in-app banner

        completionHandler(UIBackgroundFetchResultNewData);

    }
}
Pramuka Dias
  • 568
  • 4
  • 16
  • @Ewan Mellor ,@Anbu.Karthik .Ok .Tell me ,Are there any way to save push notification data when app is suspended state? – Pramuka Dias Aug 10 '16 at 10:07

1 Answers1

0

This is completely normal. If you check the console log for the device, you will see a message from the system stating that it will not wake-up the app because it was terminated by the user.

Avi
  • 7,469
  • 2
  • 21
  • 22
  • The problem is not called application:didReceiveRemoteNotification:fetchCompletionHandler when app is in suspend or not running state.Application does not want to open when notification received – Pramuka Dias Aug 10 '16 at 10:01
  • Apple documentation is clear. You are seeing the designed and intended behavior. If you want to know what else you can do, you have to ask another question. Warning: that question, too, has already been asked and answered. – Avi Aug 10 '16 at 10:05
  • Instead of being a know it all you could've posted the link to that question @Avi – Rick van der Linde Aug 12 '16 at 13:13
  • It's not my job to track down such information. If the OP wants it, he knows how to find it. If nothing else, posting the question will get an answer or a link to the question he duplicated. I answered the question posted here, and that's enough. – Avi Aug 12 '16 at 15:21