Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:19:40+00:00 2026-06-15T02:19:40+00:00

I want my app to do specific things when the app is launched by

  • 0

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.

When the app is started from background by a click on the notification, I get the notification via:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

=> NO PROBLEM !

When the app is started from scratch by a click on the notification, I would like to get the notification via:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

     UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

}

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).

Anybody knows how to solve this issue ?

Thanks !!!

EDIT 1

Here is how my notifications are created (Joe question):

  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];

EDIT 2 (ANSWER TO MY QUESTION! :))

Here is the procedure I used to debug my app but…this procedure is wrong!!

  1. I set up my debugger with the “Wait for MyApp.app to launch” option in the “Edit Scheme” menu
  2. 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
  3. The app is launched => I clicked on the home button => the notification is displayed
  4. 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
  5. => launchOptions is nil !

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…

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:

- (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;
}

Thanks all for your help !!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:19:41+00:00Added an answer on June 15, 2026 at 2:19 am

    I could not find an error in the code you shared. Normally this should work both in the simulator, and on the device. Here is an example that worked for me: First generate a new Single View iPhone app (ARC and Storyboards on). Then change two methods in the AppDelegate as follows:

    - (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;
    }
    
    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        [[UIApplication sharedApplication] cancelAllLocalNotifications];
    
        UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        localNotif.fireDate = [NSDate dateWithTimeInterval:10.0 sinceDate:[NSDate date]];
        localNotif.timeZone = [NSTimeZone defaultTimeZone];
        localNotif.alertBody = @"Just some text";
        localNotif.alertAction = @"OK";
        localNotif.soundName = UILocalNotificationDefaultSoundName;
        localNotif.applicationIconBadgeNumber = 1;
        localNotif.userInfo = @{@"test": @YES};
    
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    }
    

    Then start this app, press the home button, then stop the app. If you tap on the local notification which comes in 10 seconds after pressing the home button, you should see something like this, which shows the local notification has been passed to -application:didFinishLaunchingWithOptions::

    screenshot of the iPhone Simulator showing an alert view that displays a local notification

    My advice is: First get the example I posted above to work to make sure nothing has gone awry with your setup, then check what you are doing differently in your code.

    Edit

    This applies to Edit 2 of the question: Local notifications also seem to work for me when waiting for the app to launch (in the simulator, not on the device). Try this:

    1. Install the sample app described above and launch it with “Wait for MyApp.app to launch” disabled.
    2. Click on the home button, then stop the app via Xcode or via the task bar.
    3. Enable “Wait for MyApp.app to launch”.
    4. If you now tap the notification in the notification center, it is shown in the alert view.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create an iPhone app that displays (among other things) a specific
I want my app to stop playing video after specific time period (say 30
I want my app to have a specific layout for Android tablets and another
I want to develop an app to display the programs schedule of a specific
I want to check if a specific apk is present in system app folder.
I want my app to be hw accelerated in ICS, but support of 2.3.3
I want to develop an iPhone app that read data from the internet but
Background: We have app a, b, and plan to add more apps into this
I want my app to store multiple objects locally for later use. Now, my
I want my app to be available for both phones and tablets. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.