title: XCode : why launchOptions in didFinishLaunchingWithOptions always nil?
body: <p>I want my app to do specific things when the app is launched by a click on a notification. I want to do these specific things when the app is already running into background BUT ALSO when the app is started FROM SCRATCH (not running into background) by a click on the notification.</p>
  
  <p>When the app is started from background by a click on the notification, I get the notification via:</p>
  
  <pre><code>- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  </code></pre>
  
  <p>=> NO PROBLEM !</p>
  
  <p>When the app is started from scratch by a click on the notification, I would like to get the notification via:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
  
       UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
  
  }
  </code></pre>
  
  <p>But launchOptions is always nil !! It is nil when the app is started from scratch via a click on the app icon (normal) but also when the app is started from scratch via a click on a notification (not normal).</p>
  
  <p>Anybody knows how to solve this issue ?</p>
  
  <p>Thanks !!!</p>
  
  <p>EDIT 1</p>
  
  <p>Here is how my notifications are created (Joe question):</p>
  
  <pre><code>  NSDictionary *userInfo = [NSDictionary dictionaryWithObjects:
  [NSArray arrayWithObjects:notifText,latitudeString,longitudeString,nil]
  forKeys:[NSArray arrayWithObjects:@"notifText",@"latitude",@"longitude", nil]];
  
      UILocalNotification *localNotif = [[UILocalNotification alloc] init];
      localNotif.fireDate = itemDate;
      localNotif.timeZone = [NSTimeZone defaultTimeZone];
      localNotif.alertBody =msg;
      localNotif.alertAction = @"Ok";
      localNotif.soundName = UILocalNotificationDefaultSoundName;
      localNotif.applicationIconBadgeNumber = 1;
      localNotif.userInfo = userInfo;
  
      [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
      [localNotif release];
  </code></pre>
  
  <p><strong>EDIT 2 (ANSWER TO MY QUESTION! :))</strong></p>
  
  <p>Here is the procedure I used to debug my app but...this procedure is wrong!!</p>
  
  <ol>
  <li>I set up my debugger with the "Wait for MyApp.app to launch" option in the "Edit Scheme" menu</li>
  <li>I launched my app with XCode a first time (launch from scratch) XCode displays the "Waiting for my MyApp to launch" => I CLICKED ON MY APP ICON to launch the app</li>
  <li>The app is launched => I clicked on the home button => the notification is displayed</li>
  <li>I clicked on the stop button in XCode to close the app I relaunched it with XCode => XCode displays again the "Waiting for my MyApp to launch" message => I CLICKED ON THE
  NOTIFICATION in the status bar to launch the app</li>
  <li>=> launchOptions is nil !</li>
  </ol>
  
  <p>launchOptions equal to nil is due to the fact that relaunching the app with XCode (in this case with the "Waiting for my MyApp to launch" option) deletes the notifications even if it is still displayed in the status bar... </p>
  
  <p>To be able to debug check what is the content of launchOptions after a relaunch of the app from scratch by a click on a notification, it seems that the only way is to display this content in a UIAlert as mentioned in answer by Tammo Freese. So, use the following to debug in this specific case:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"options" message:[launchOptions[UIApplicationLaunchOptionsLocalNotificationKey] description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
      [alertView show];
      return YES;
  }
  </code></pre>
  
  <p>Thanks all for your help !!!!</p>