- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"application: didFinishLaunchingWithOptions:");
// Override point for customization after application launch
UILocalNotification *localNotif = [launchOptions
objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
// has notifications
}
else {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
[window makeKeyAndVisible];
return YES;
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif {
NSLog(@"application: didReceiveLocalNotification:");
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = [NSDate date]; // show now, but you can set other date to schedule
localNotif.alertBody = @"this is a notification!";
localNotif.alertAction = @"notification"; // action button title
localNotif.soundName = UILocalNotificationDefaultSoundName;
// keep some info for later use
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"item-one",@"item", nil];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments
comments