ios 本地通知
来源:互联网 发布:吃饭排队叫号软件 编辑:程序博客网 时间:2024/06/07 00:15
UILocalNotification *notification=[[UILocalNotification alloc] init]; if (notification!=nil) { NSDate *now = [NSDate date]; //从现在开始,10秒以后通知 notification.fireDate=[now dateByAddingTimeInterval:10];
//notification.fireDate = [NSDate dateWithTimeIntervalSince1970:8*60*60];//8点通知 //使用本地时区 notification.timeZone=[NSTimeZone defaultTimeZone]; notification.alertBody=@"顶部提示内容,通知时间到啦"; //通知提示音 使用默认的 notification.soundName= UILocalNotificationDefaultSoundName; notification.alertAction=NSLocalizedString(@"你锁屏啦,通知时间到啦", nil); //这个通知到时间时,你的应用程序右上角显示的数字。 notification.applicationIconBadgeNumber = 1; //add key 给这个通知增加key 便于半路取消。nfkey这个key是我自己随便起的。 // 假如你的通知不会在还没到时间的时候手动取消 那下面的两行代码你可以不用写了。 NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:notificationtag],@"nfkey",nil]; [notification setUserInfo:dict]; //启动这个通知 [[UIApplication sharedApplication] scheduleLocalNotification:notification]; //这句真的特别特别重要。如果不加这一句,通知到时间了,发现顶部通知栏提示的地方有了,然后你通过通知栏进去,然后你发现通知栏里边还有这个提示 //除非你手动清除,这当然不是我们希望的。加上这一句就好了。网上很多代码都没有,就比较郁闷了。 [notification release];}
//每1分钟提醒一次
notification.repeatInterval= NSMinuteCalendarUnit;
//每1小时提醒一次
notification.repeatInterval= NSHourCalendarUnit;
//每1天提醒一次
notification.repeatInterval=NSDayCalendarUnit;
0 0
- iOS 本地通知 远程通知
- iOS本地通知 远程通知
- iOS本地通知&定时通知
- iOS实现本地通知
- iOS本地通知
- iOS本地通知
- iOS本地通知UILocalNotification
- IOS实现本地通知
- IOS 本地通知 UILocalNotification
- ios本地通知UILocalNotification
- iOS UILocalNotification本地通知
- iOS实现本地通知
- iOS实现本地通知
- IOS实现本地通知
- iOS-本地通知
- IOS 本地通知
- IOS本地推送通知
- iOS本地通知:UILocalNotification
- 向量内积和夹角的关系
- Nginx配置文件nginx.conf中文详解
- NYOJ 746 整数划分(四)区间DP
- 如何调优JVM - 优化Java虚拟机
- HDFS的dfs.replication不同验证
- ios 本地通知
- Javascript语义分析器,教你如何实现Jquery库
- Python非root用户启动python multiprocessing的semlock,提示没有权限的解决方法
- Ejabberd外部组件开发
- Unity内部类实现GPS定位
- css3实现六边形照片展示
- BAT 批处理脚本 教程
- HTTP Live Streaming服务器的搭建
- Lucence的Field属性整理