7
votes

I am currently facing a problem with push notifications in iOS.

My app receives silent push notifications containing an identifier. This identifier is then used to fetch data from a remote server from which a local notification is created.

As far as I'm aware, if the user has force-quit an app (i.e. by double tapping the home button and swipe closing the app) then the silent push notification does not get passed onto the didReceiveRemoteNotification method in the AppDelegate class [1] [2], thus preventing the app from doing any kind of processing.

I have done a fair amount of research into handling the situation mentioned above. However, was unable to find a definitive answer and was hoping someone could help me out or point me in the right direction.

TLDR: What should I do when the user has force-quit my app, but I still need to process a silent notification?

Further Information:
My app only needs to support iOS8+.

[1] https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

The Notification Payload
If the target app isn’t running when the notification arrives, the alert message, sound, or badge value is played or shown. If the app is running, the system delivers the notification to the app delegate as an NSDictionary object.

[2] https://stackoverflow.com/a/19202487/2472819

1
Short answer: There is nothing you can do in this case. In my opinion, if a user force-quits an app, he has no right to expect that the app will function properly.Baris Akar
Force-quit is a way of killing a badly behaved app, which is probably why it prevents notifications being handled. Unfortunately some online sources still tell users to close all apps, although this is unnecessary.Peter Johnson
What's crazy is that I see loads of people force-closing apps to save battery. even developers.joshblour

1 Answers

1
votes

Previously in iOS 7 and before, once a user force-quit an app, it will not be able to run and background tasks at all, including location monitoring, push notification handling with content-available:1 etc.

However the problem is that such behavior is not documented. The reason is that it may change in a new iOS update and Apple doesn't want to nail the coffin too early. As in iOS 8, PushKit is introduced and is supposed to be able to deal with the force-quit scenario. Please check this tutorial for details: https://zeropush.com/guide/guide-to-pushkit-and-voip