使用UILocalNotification 添加本地通知事件

UILocalNotification *notification=[[UILocalNotification allocinit]; 

if (notification!=nil) { 

NSLog(@">> support local notification"); 

      notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10]; 

      notification.timeZone=[NSTimeZone defaultTimeZone]; 

      notification.alertBody=@"该去吃晚饭了!"

      [[UIApplication sharedApplication]   scheduleLocalNotification:notification];

}


UILocalNotification需要4.0版本支持!!


应用程序启动后,当10秒钟过去后,如果应用还是在前台运行,而且应用委托实现- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification方法,

则会进入该函数;


如果10秒过后,应用在后台或,则会弹出alert框提示用户;


注意: 对本地通知的数量限制,iOS最多允许最近本地通知数量是64个,超过限制的本地通知将被iOS忽略。

获取本地所有已经添加的通知

[[UIApplication sharedApplication] scheduledLocalNotifications]; 


来源 http://blog.csdn.net/studyrecord/article/details/6604696 

国外一篇介绍的非常好 http://www.iostipsandtricks.com/ios-local-notifications-tutorial/

原文地址:https://www.cnblogs.com/likwo/p/2186500.html