Reputation: 12499
According to the Local and Remote Notification Programming Guide, when a remote notification is delivered and you tap the app icon in the SpringBoard:
The user taps the default button in the alert or taps (or clicks) the app icon. If the default action button is tapped (on a device running iOS), the system launches the app and the app calls its delegate’s application:didFinishLaunchingWithOptions: method, passing in the notification payload (for remote notifications) or the local-notification object (for local notifications).
If the notification is remote, the system also calls application:didReceiveRemoteNotification:fetchCompletionHandler:.
However, when I see the remote notification badge and I tap the app icon, neither application:didFinishLaunchingWithOptions:
(app would be running in background), nor application:didReceiveRemoteNotification:
, nor application:didReceiveRemoteNotification:fetchCompletionHandler:
are called...
I successfully get the push notification's payload when tapping a banner or an alert, how could I also get it when tapping the app icon?
Thanks
Upvotes: 1
Views: 794
Reputation: 6900
I'm running into the same issue and unfortunately like Paulw11 said, your app will receive no information on the payload. However! I have noticed that the badge number will reflect the missed notitfication, so on app launch you can check if your applicationBadgeNumber != 0
and if it is not, you can query your server for the last data that was sent.
Upvotes: 0
Reputation: 114846
You need to continue reading. The remainder of the section you quoted reads -
If the app icon is clicked on a computer running OS X, the app calls the delegate’s applicationDidFinishLaunching: method in which the delegate can obtain the remote-notification payload. If the app icon is tapped on a device running iOS, the app calls the same method, but furnishes no information about the notification.
Note the section I bolded. The short answer is that if the application is launched from the app icon then no information is provided about any notifications that may have been received.
Upvotes: 2