0

According to Apple's documentation on remote notifications:

Discussion

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 remote 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.

In my case (iOS 7.1.1) remote notification is not delivered to the app after the app was killed (swipe up from Recent Apps List) and the phone was restarted. If I open the app, notifications get delivered as expected. What am I missing?

Edit: To avoid any misunderstanding. What I expect is the following flow:

  1. User kills the app;
  2. User restarts the phone;
  3. App server sends a new message;
  4. OS attempts to launch the app and deliver the notification.
Asahi
  • 13,378
  • 12
  • 67
  • 87
  • *"What am I missing?"* - it does not sound like you are missing anything :) Its sounds like expected (but undesired) behavior. I'd like to start getting that [`applicationWillTerminate:`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/#//apple_ref/occ/intfm/UIApplicationDelegate/applicationWillTerminate:) that they claim is supposed to be sent to clean-up in a security context :) Apple docs suck at times. – jww Jun 05 '15 at 20:40
  • @jww: Expected? I am afraid this is the case, but is there any confirmation of that? – Asahi Jun 05 '15 at 20:42
  • The behavior you are seeing is *exactly* what is documented by Apple: The system will not automatically launch your app to deliver a remote notification if the user has force-quit your app. It is very clearly stated in the text that you copied, in bold. – RyanR Jun 05 '15 at 21:34
  • @RyanR: If you read the entire quote, in bold, you will discover that the system will attempt to deliver notifications after user re-launched the app or restarted the device. – Asahi Jun 06 '15 at 08:01
  • @Asahi I think you are misunderstanding. The system will not cache your remote notifications until your app is relaunched. As you are experiencing exactly this behavior, and 2 other developers are confirming that behavior... – RyanR Jun 06 '15 at 16:25
  • @RyanR Please see edit – Asahi Jun 06 '15 at 17:54

2 Answers2

3

The problem is that you are a developer, and your usage is not typical. What you do: Launch the app, swipe it out, turn off the phone (not standby, but turned off), reboot, enter your passcode, make your server send a notification. That doesn't work.

For some reason, notifications sent within 90 seconds or so after rebooting the phone are not received. Wait 90 seconds, then you send the notification, and it should be received. Since there is no relation between the time the phone of the user is rebooted and the time you send the notification, this is only a problem for developers and testers, not for real users.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • It can actually be longer than 90 seconds, cf. https://stackoverflow.com/questions/58525436/ios-silent-push-notification-not-delivered-after-device-reboot, see also https://stackoverflow.com/questions/68983220/ios-push-notifications-what-is-thunderingherdpolicy. – jakobleck Oct 11 '22 at 16:24
0

From the article you linked, for the method you're referencing (application:didReceiveRemoteNotification:)

If the app is not running when a remote notification arrives, the method launches the app and provides the appropriate information in the launch options dictionary. The app does not call this method to handle that remote notification. Instead, your implementation of the application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: method needs to get the remote notification payload data and respond appropriately.

Are you checking for your remote notification payload in the options dictionary for the will/didFinishLaunchingWithOptions:?

RyanR
  • 7,728
  • 1
  • 25
  • 39
  • yes, I am checking those as well. they don't get called either – Asahi Jun 07 '15 at 06:45
  • @Asahi You really should indicate everything you have tried in your question, that way people trying to help you have all the information about your problem, and don't waste time describing solutions you have already tried. – RyanR Jun 07 '15 at 14:30