Local notifications allow an application that isn’t running in the foreground to let its users know it has something to tell them.

Local notifications are an instance of UILocalNotification.  Available Options:

Scheduled time (including rescheduling if required).

Notification type – The alert message, the title of the action button, the application icon badge number, and a sound to play.

Custom data. Local notifications can include a dictionary of custom data.

How many notifications Can You Create?

Each application on a device is limited to the soonest-firing 64 scheduled local notifications. The operating system discards notifications that exceed this limit (recurring notifications are considered a single notification).

Links

iOS Developer Scheduling, Registering, and Handling Notifications

http://useyourloaf.com/blog/2010/7/31/adding-local-notifications-with-ios-4.html

Clearing All Local Notifications For An Application


    //----- CLEAR ALL EXISTING LOCAL NOTIFICATIONS -----
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

Create Local Notification


        //Add next local notification
        UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        if (localNotif == nil)
            break;                  //Error (old iOS version?)
        localNotif.fireDate = MyDateVariable;
        localNotif.timeZone = [NSTimeZone defaultTimeZone];

        localNotif.applicationIconBadgeNumber = 1;    //Fixed badge number (must be known at creation time - can't gbe set to increment etc)

        //TO DISPLAY A MESSAGE
        //Set Alert Text (appears under app name)
        localNotif.alertBody = @"Hello";
        //Set the action button label (appears with the 'Close' button)
        localNotif.alertAction = NSLocalizedString(@"View", nil);
        localNotif.soundName = UILocalNotificationDefaultSoundName;

        //ALTERNATIVELY TO NOT DISPLAY A MESSAGE (i.e. if you just want to update the badge number)
        localNotif.alertBody = nil;
        localNotif.hasAction = FALSE;

        //Option add dictionary containing something you want when user selects action button and app is opened
        NSDictionary *infoDict = [NSDictionary dictionaryWithObject:MyVariable
                                                             forKey:@"MyKeyName"];
        localNotif.userInfo = infoDict;

        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
        [localNotif release];

Handling Notification – Application Not Running

The notification is created by the system. If the user presses ‘Close’ then nothing more happens – you can’t force your application to be run. If the user presses the ‘alertAction’ button you created then you can obtain the dictionary information you stored using ‘didFinishLaunchingWithOptions’ function (if your app currently uses applicationDidFinishLaunching then convert to this function to access the information).

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


    //----- GET THE LOCAL NOTIFICATION INFORMATION IF WE HAVE BEEN RUN FROM THE USER PRESSING THE ACTION BUTTON OF ONE OF OUR NOTIFICATIONS -----
    UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (localNotif)
    {
        NSString *NotificationValue = [localNotif.userInfo objectForKey:@"MyKeyName"];        //objectForKey:TheKeyNameYouUsed

        NSLog(@"Run with notification value: %@", NotificationValue);
    }

Handling Notification – Application In Background or Application In The Foreground


//*************************************************************
//*************************************************************
//********** APPLICATION RECEIVED LOCAL NOTIFICATION **********
//*************************************************************
//*************************************************************
//This occurs:
//  Application is in the background (notification has been shown to user and user has pressed the action button)
//  Application in the foreground (notification has not been shown to the user, does not occur is device has been locked even if app is still the foreground app)
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    //----- GET THE LOCAL NOTIFICATION INFORMATION IF WE HAVE BEEN RUN FROM THE USER PRESSING THE ACTION BUTTON OF ONE OF OUR NOTIFICATIONS -----
   NSString *NotificationValue = [notification.userInfo objectForKey:@"MyKeyName"];        //objectForKey:TheKeyNameYouUsed

    NSLog(@"LOCAL NOTIFICATION RECEVIED, value: %@", NotificationValue);

    if (NotificationValue)
    {
        //----- VIEW NOTIFICATION -----
        UIApplicationState state = [application applicationState];
        if (state == UIApplicationStateInactive)
        {
            //----- APPLICATION WAS IN BACKGROUND - USER HAS SEEN NOTIFICATION AND PRESSED THE ACTION BUTTON -----
            NSLog(@"Local noticiation - App was in background and user pressed action button");

        }
        else
        {
            //----- APPLICATION IS IN FOREGROUND - USER HAS NOT BEEN PRESENTED WITH THE NOTIFICATION -----
            NSLog(@"Local noticiation - App was in foreground");

        }
    }
}