Reputation: 51
I implemented the support for push notification and it is working like a charm. However, in one particular scenario, it doesn't give me the desired result.
When the app is running (state is either active or is in background), whenever a push notification is received, the function "didReceiveRemoteNotification" is called. BUT, when the app is terminated and a push notification is received, I believe "didReceiveRemoteNotification" NEVER gets called (can't test this scenario using Xcode as app hasn't been launched yet). This prevents me from loading a particular view controller to the user.
Can someone please tell me how I can get the data corresponding to the push notification when received while the app hasn't been launched yet? Is there some other function that I need to look into for this particular scenario ONLY?
Appreciate some help.
Upvotes: 0
Views: 130
Reputation: 31782
Per the documentation:
If the app is not running when a push notification arrives, the method launches the app and provides the appropriate information in the launch options dictionary. The app does not call this method to handle that push notification. Instead, your implementation of the
application:willFinishLaunchingWithOptions:
orapplication:didFinishLaunchingWithOptions:
method needs to get the push notification payload data and respond appropriately.
In particular, the key you should be looking for in the launch options dictionary is UIApplicationLaunchOptionsRemoteNotificationKey
.
Upvotes: 1