Considering that I receive a pushed notification on my iPhone.
What happens:
- If the application is started: is there a way to get the payload? Do I see the notification on my screen?
- If the application is not started, is there a way to get the payload?
Thx for your answers
First of all push notifications are not “strong”, if you simply let a notification sit for long enough (e.g. phone turned off for many days) it will get discarded. You need to do some custom back-end processing to persist the content sent in notifications.
In the UIApplicationDelegate
protocol there’s application:didFinishLaunchingWithOptions:
. If your app is launched by the user tapping the right button in an alert of a push notification, the launchOptions
dictionary bound to the method call will contain information regarding that notification; if your app is already running then application:didReceiveRemoteNotification:
(also in the delegate protocol) will get called instead.
So,
If the application is started, and you implement application:didReceiveRemoteNotification:
then yes you get the payload. Otherwise, nothing happens.
If the application is not started at the time the notification is sent, then the user taps on the alert of the notification and launches your app, your app gets the payload if it implements application:didFinishLaunchingWithOptions:
. Otherwise, you get nothing.