3
votes

I’m building an app which handles notifications pushed from Parse, and trying to create a notification history function. I’ve enabled the background modes successfully, so when the app is running in the background, the app can get the payload well via application:didReceiveRemoteNotification:fetchCompletionHandler even the banner/alert is not tapped. However, when force-quit / swipe up to kill the app, application:didReceiveRemoteNotification:fetchCompletionHandler is not called.

Is there any method to implement for getting the push notification payload when the app is killed without tapping the banner/alert? Thank you in advance!

1
application:didReceiveRemoteNotification:fetchCompletionHandler works only when app is running. How can you call a function of an app when its not running? And what will you do with the data when app is not running? It needs to be handled only when app runs foreground/background.iphonic
Thanks for the reply! I'm trying to create a notification history function, which displays all the notification received with a Tableview, so I hope that every time when a notification arrives even when the app is killed, the app can still get the payload when it is re-launched, and display the content. If there is no method for the purpose, are there any other approaches to make this possible?Alison
Is this an implicit operating system level policy? Why doesn't iOS start the app in background if it receives a silent (content-available: 1) push notification? Is there any local mechanism by which I can schedule jobs/tasks/timers at the OS level, such that when the timer expires my app gets started in background if it was killed?Alex Bitek
@Alison have you find any solution? Currently I am struggling with the same.Beu

1 Answers

6
votes

You can't get a notification's payload if your app is killed.

In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system. When password protection is enabled on the device, the system does not launch an app in the background before the user first unlocks the device. - Understanding When Your App Gets Launched into the Background

Anyway, push notifications are not reliable.
It means that you can not be sure that they will ever be delivered.

If you want to keep a "notification history" list, do it server-side and fetch it in-app (in a totally not push related way).

Each time you send a push notification, keep it's content in database, like any object. Then when the user opens the history list, fetch the list like any other parse object.