Reputation: 131398
I'm developing an app for a client that needs to be able to receive push notifications while running in the background.
I set up the all the annoying certificates and other security cruft to run the sandbox ARNs, and collected ARNs tokens from several test devices:
An iPhone 5 running iOS 8.4.1 An iPhone 6 running iOS 9.1 An iPhone 4s running iOS 7.0.4
The app has the remote-notification UIBackgroundMode set in its info.plist and I'm including the content-available
key in my notification payload.
I'm also making the UIApplication registerForRemoteNotifications
call at startup (or the now-deprecated registerForRemoteNotificationTypes
method call for the iOS 7 device.)
On the iPhone 6 and on the 4s, sending a remote notification launches the app in the background if it's not running, as expected.
On the iPhone 5, however, the app does not get launched if it is not running.
If I specify the default remote notification sound it does play.
If I send the remote notification with the {"alert":1}
key/value pair, the device displays a remote notification, and tapping/sliding on the notification DOES launch the app.
I've tried manually launching the app in case I had force-quit it. (On the other test devices force-quitting the app blocks launching into the background until I either restart the device or manually launch the app again, as described in Apple's docs.)
The fact that the other test devices behave as expected, and the fact that the iPhone 5 plays the notification sound if requested, and displays the notification banner if requested, tells me that I have things set up correctly.
The question is, why isn't the iPhone 5 launching into the background like the other devices do?
Upvotes: 1
Views: 102
Reputation: 4003
Check if background refresh is disabled for this app (or all apps) in the iPhone 5 in the settings.
To check this from your code: [[UIApplication sharedApplication] backgroundRefreshStatus]
Upvotes: 2