计划应用程序本地通知
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计划应用程序本地通知相关的知识,希望对你有一定的参考价值。
Show a notification immediately after application enter in background (but you can schedule it too)
- (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.alertBody = @"this is a notification!"; localNotif.alertAction = @"notification"; // action button title localNotif.soundName = UILocalNotificationDefaultSoundName; // keep some info for later use localNotif.userInfo = infoDict; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; [localNotif release]; }
以上是关于计划应用程序本地通知的主要内容,如果未能解决你的问题,请参考以下文章