application: didReceiveRemoteNotification: fetchCompletionHandler:
is different from
application: didReceiveRemoteNotification:
The Apple docs are a bit confusing
application: didReceiveRemoteNotification: fetchCompletionHandler:
is used if your application supports the remote-notification background mode (ie you're doing BackgroundFetch.)
application: didReceiveRemoteNotification:
is called when the OS receives a RemoteNotification and the app is running (in the background/suspended or in the foreground.)
You can check the UIApplicationState to see if the app was brought to foreground by the user (tapping on notification) or was already running when notification comes in.
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState];
// user tapped notification while app was in background
if (state == UIApplicationStateInactive || state == UIApplicationStateBackground) {
// go to screen relevant to Notification content
} else {
// App is in UIApplicationStateActive (running in foreground)
// perhaps show an UIAlertView
}
}