We're relatively new to iOS push notifications, and as always with Apple, I'm impressed by the elegance of the solution, but also slightly infuriated by what appears to be some opaque 'behind the scenes' management of the feature's behaviour.
My question is this: After successfully receiving approx. 10 separate silent push notifications at a rate of one per hour, no more were delivered to our test app until it was finally opened by our test user. Based on this it appears that iOS may stop delivering silent push notifications if it determines an app is not in use. Is this expected behaviour? Does anyone know any rough details about the heuristic used by Apple for this?
Details of the testing for those interested
FYI, our test set up is as follows:
- We have built a simple Notification test app (built for iOS7 using the
application:didReceiveRemoteNotification:fetchCompletionHandler
delegate method) - For the duration of the test the app was kept in suspended state in the background on our test iPhone 5 (sometimes in the office on wifi, sometimes on 3G in and around London).
- We have a simple Ruby script using the Grocer gem (which seems very good incidentally) sending a silent push notification every hour to the app, via Apple's sandbox APNS gateway.
- When the app receives the notification it wakes up, writes a log and makes a simple request to our backend server, which also logs the event having occurred.
Results:
- Everything works exactly as expected for the first 10 hours. After this no more notifications are received by the app.
The notification format (manually copied out, excuse any errors):
aps = {
badge = 2;
"content-available" = 1;
};