Search code examples
iosapple-push-notifications

Is a iOS silent notification received when the app is killed


when sending a background push with "content-available": "1", to an app that is killed by the user, the application is not launched into the background mode and the application:didReceiveRemoteNotification:fetchCompletionHandler: is not called as the Apple doc say:

Use this method to process incoming remote notifications for your app. [...]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.

My question is: Is there is any way to access this silent push payload the next time the user starts the application?

I tried using the launchOptions of the didFinishLaunchingWithOptions method but they do not contain the push payload.

NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];

My use case is that I rely only on the push channel to receive data to the app but the app cannot pull them.


Solution

  • Short answer is: no, you cannot.

    You also won't be able to use VoIP pushes, the only option would be to use regular pushes with a push notification service extension. Share a keychain between your app and this extension, save the push payload in the keychain when receiving a notification and retrieve it with your app when it enters foreground. Downside is you will need to present a visual notification to the user, but it can be silent, and you can choose to present whatever text you want (the best option will depend on what your app does and what's the purpose of this notification).