- #pragma mark 添加本地通知
- -(void)addLocalNotification{
- //定义本地通知对象
- UILocalNotification *notification=[[UILocalNotification alloc]init];
- //设置调用时间
- notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10.0];//通知触发的时间,10s以后
- notification.repeatInterval=2;//通知重复次数
- //notification.repeatCalendar=[NSCalendar currentCalendar];//当前日历,使用前最好设置时区等信息以便能够自动同步时间
- //设置通知属性
- [email protected]"最近添加了诸多有趣的特性,是否立即体验?"; //通知主体
- notification.applicationIconBadgeNumber=1;//应用程序图标右上角显示的消息数
- [email protected]"打开应用"; //待机界面的滑动动作提示
- [email protected]"Default";//通过点击通知打开应用时的启动图片,这里使用程序启动图片
- //notification.soundName=UILocalNotificationDefaultSoundName;//收到通知时播放的声音,默认消息声音
- [email protected]"msg.caf";//通知声音(需要真机才能听到声音)
- //设置用户信息
- [email protected]{@"id":@1,@"user":@"Kenshin Cui"};//绑定到通知上的其他附加信息
- //调用通知
- [[UIApplication sharedApplication] scheduleLocalNotification:notification];
- }
来源: http://www.phpxs.com/code/1005582/