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 8787009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:46:39+00:00 2026-06-13T21:46:39+00:00

According to Apple docs on UILocationNotification.fireDate : If the specified value is nil or

  • 0

According to Apple docs on UILocationNotification.fireDate:

If the specified value is nil or is a date in the past, the
notification is delivered immediately.

I am not seeing this behavior when using a date in the past. Is it just me, or are others seeing this as well?

Here is my code:

NSMutableArray *notifications = [NSMutableArray array];
UILocalNotification* alarm = [[UILocalNotification alloc] init];
alarm.fireDate = [NSDate dateWithTimeIntervalSince1970:time(NULL)-5];
alarm.repeatInterval = 0;
alarm.soundName = @"alarm.caf";
alarm.alertBody = @"Test";
alarm.alertAction = @"Launch";
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
[userInfo setValue:[NSNumber numberWithInt:10] forKey:@"PsID"];
alarm.userInfo = userInfo;
notifications = [NSArray arrayWithObject:alarm];
UIApplication *app = [UIApplication sharedApplication];
app.scheduledLocalNotifications = notifications;

If I change the time(NULL)-5 to time(NULL)+5 I get the notification 5 seconds after this code runs. With the -5 value, I never get the notification.

I know good questions here need to have a possible definite answer and this could be subject to a lot of “me too” answers — so what I’m looking for is something official (quote/link) from Apple saying this is expected behavior, or different version of the above code that works as the docs say it should.

This is important for my application because in some cases I need to notify the user of an alarm even if it happened earlier in the day. I suppose I could modify my code to check the current time and always give a value a few seconds beyond that — but I’m not sure “how many seconds beyond” is really safe, and I would like it to happen ASAP — also rather not have that hack if there is a better way to get “documented behavior”. My real code is similar to above, but I am posting several notifications, some might be in the past, some later today, some tomorrow and beyond (this is for a calendar application).

  • 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-13T21:46:41+00:00Added an answer on June 13, 2026 at 9:46 pm

    @eselk,

    I see the same behavior as you: a newly-created UILocalNotification that has a fireDate in the past will NOT fire if it is installed by setting the scheduledLocalNotifications property on the UIApplication object.

    However, if the same UILocalNotification object is installed using UIApplication’s scheduleLocalNotification method, it will fire immediately.

    Seems to me to be a bug based on the documentation for scheduledLocalNotifications, which states pretty clearly that:

    …When you set [the scheduledLocalNotifications] property, UILocalNotification
    replaces all existing notifications by calling
    cancelLocalNotification: and then calling scheduleLocalNotification:
    for each new notification.

    Given that this doesn’t seem to be the case, the workaround is to call scheduleLocalNotification if your application logic requires that notifications that are scheduled in the past need to be presented to the user.

    UILocalNotification *ln = [[UILocalNotification alloc]init];
    [ln setFireDate:[NSDate dateWithTimeIntervalSinceNow:-2]]; // two seconds ago
    // ...
    
    // the following line works as expected - the notification fires immediately
    [application scheduleLocalNotification:ln];  // Using this line works as expected
    
    // using the following does NOT work as expected - the notification does not fire
    //application.scheduledLocalNotifications = [NSArray arrayWithObject:ln];
    

    (I tested this on the iOS 6 simulator)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to Apple's docs, Subclasses need not override -[UIView drawRect:] if the subclass is
According to Apple Docs NSCalendar is not thread-safe . How can I ensure thread-safety
According to the Apple docs, MKPinAnnotationView's pin color is available in red, green and
According to Apple's gcc 4.2.1 doc : -arch arch Compile for the specified target
I know it might not be according to Apple's human interface guidelines for the
According to Apple documentation and other documentation I have read about on disk encryption
According to Apple's description, the aurioTouch sample app is suppose to get the audio
According to Apple's OpenGL ES Programming Guide , If [a] framebuffer is intended to
According to Apple; missing network alerts is the third most common reason for applications
According to Apple's Objective C guide, methods with the same name all use the

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.