First of all, application is always launched with the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method. You shall examine the launchOptions dictionary to check if the app was opened because of a notification. In that launch method you can access the notification object this way:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
{
// setup navigation controller here, I assume you already have this in your code
NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil)
{
NSLog(@"%@: did launch with notification: %@", [self class], dictionary);
// put the navigation controllers on the nav controller stack as David described
}
[[self window] setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
The method - (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
will be called ONLY if the app had already been launched. It could be called when the app is switching from background to foreground or when it runs. This method is never called when the application starts as a new process.