Hamzah Malik
Hamzah Malik

Reputation: 2570

Is there a way to awaken an iOS app upon receiving a push notification even when it is killed

I need a way to receive a silent push notification, and then display a local one (so I can process data before displaying to user) Is there a way to do this? didReceiveNotification is only called when in the foreground. I believe the app is launched when in background upon receiving push. However, there does not seem to be a solution for when the app is killed.

EDIT I am aware of PushKit but my app is not a VOIP app, it is an IM app.

Upvotes: 9

Views: 764

Answers (1)

Paulw11
Paulw11

Reputation: 114783

You can use the UIApplicationDelegate method didReceiveRemoteNotification: to receive a 'silent' push when your app is in the foreground or background, but If your app is killed (force-quit from the switcher) then there is no way to receive the notification in your app. The notification payload (if any) will still be displayed to the user, giving them the opportunity to launch your app from the notification.

The documentation for this delegate method states:

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

Upvotes: 11

Related Questions