Case 1:
When the app is not in memory(neither in background mode nor in foreground mode) the user has two choices
either open the app by clicking on the notification received
or open the app directly by clicking on the app icon
In these cases
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
is called where you can get the notification (if any) using this
NSDictionary* remoteNotification=[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
Case 2:
But when the app is either in background or in foreground mode, then
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
is executed, so there you can fetch your data with respect to the notification received.
And if in these modes also user tries to click on the notification then again
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
is called and there you can handle the notification data like in Case 1.
Hope this will help.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…