The device consists mainly of four push notification states. Consider one after another each case: -
CASE 1: when the application is really not loaded into memory (for example, when you launch it, a splash screen will appear, etc.), then the application is called: didFinishLaunchingWithOptions, and you can get push push as follows:
NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if(remoteNotif) {
CASE 2: if the application is loaded into memory and is ACTIVE (for example, the application is open on the device), then only the application: (UIApplication *) didReceiveRemoteNotification: (NSDictionary *) userInfo is called. Normal, as you said, in this case.
CASE 3: if the application is loaded into memory, but is not ACTIVE and DOES NOT ASSUME (for example, you started the application, then pressed the home button and waited 10 seconds), and then you press the action button on the push notification, only doReceiveRemoteNotification is called . follow the approach below.
-(void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *)userInfo { if([app applicationState] == UIApplicationStateInactive) {
CASE 4: when the application is in the background, and then click the icon, and then according to Apple's documentation, you will not be able to receive all pending notifications.
Note To solve this problem, Apple introduces the concept of launching a background launch of an application in iOS 7. But until now, you cannot do this before developing iOS 6, which you must get stuck on it.
Hope this helps you!