2

I want to fetch Apple push notification payload without clicking on push notification that i have received when my app is in background. I want to get payload when i click on app icon and app comes to foreground.

I can get payload if i click on notification. But this is not what i want.

I just want a hint if it is possible to get payload without clicking push notification.

Update

i have set UIBackgroundModes as

"Required background modes" and added "App downloads content in response to push notifications" in its value.

now,

I have implemented below method in my appdelegate.m file. But i am unable to get userInfo. This methods doesn't get call on receiving APNS.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
    NSLog(@"userInfo :: %@",userInfo);
    //Success
    handler(UIBackgroundFetchResultNewData);
}
Community
  • 1
  • 1
Alap Anerao
  • 2,083
  • 22
  • 27

2 Answers2

0

With standard push notifications it is not possible to get the payload unless the user taps the OK button on on the notification alert view. You need to query your server at the app startup, in order to figure out changes/notifications have taken place or been sent.

Alternatively you could have a look at background push notifications, which will wake up your app in the background. However these are only available in iOS 7 and above.

gabriel_101
  • 773
  • 3
  • 19
0
  • No way to fetch in case, if you kill your app from the app switcher (i.e. swiping up to kill the app) then the OS will never relaunch.

  • Otherwise, We have the fetch notification payload By remote-notification UIBackgroundModes enabled.

Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background. In addition, if you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) and puts it in the background state when a push notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

virus
  • 1,203
  • 13
  • 21
  • will help to you for sort out issue:[ http://stackoverflow.com/questions/5056689/didreceiveremotenotification-when-in-background ] – virus Aug 25 '14 at 13:54