Is there any delegate which gets called wh开发者_StackOverflow社区en we tap on the "View" button of Push Notification alert. This is when App is inactive.
Yes there is. It is application:didFinishLaunchingWithOptions:
. From the Apple docs:
If the action button is tapped, the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications). If the application icon is tapped, the application calls the same method, but furnishes no information about the notification.
Here is the reference: Local and Push Notification Programming Guide Look at the Handling Local and Remote Notifications section.
From a glance at the Push Notification docs, it looks like you get the notification in application:DidFinishLaunchingWithOptions:
and can retrieve the notification info from the options dictionary using UIApplicationLaunchOptionsRemoteNotificationKey
.
There is no way to get notification payload when app is in background, because when icon is tapped applicationDidEnterForeground is called and in this method we cannot access launchOptions OR userInfo dictionary.
精彩评论