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.