IOS 本地通知
操作流程
1.接收通知
2.注册发送通知
用途:提示时间,闹钟
//接收本地通知(在Appdelegate里面实现)
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
//接收到通知之后的操作
UIAlertView *aler = [[UIAlertView alloc]initWithTitle:notification.alertTitle message:notification.alertBody delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[aler show];
}
注册,发送通知的方法
-(void)pushNotfation{
//初始本地通知的方法
UILocalNotification *not =[[UILocalNotification alloc]init];
not.fireDate =[NSDate dateWithTimeIntervalSinceNow:10];
// 设置通知的标题
not.alertTitle = @"时间到";
// 设置通知的内容
not.alertBody = @"起床敲代码";
// 通过通知 传递 内容
not.userInfo = @{@"key":@"value"};
// 设置App图标上面红点显示的数字
not.applicationIconBadgeNumber = 1;
// 发送的间隔
not.repeatInterval =kCFCalendarUnitMonth;
/*
NSCalendarUnitEra = kCFCalendarUnitEra,一个世纪
NSCalendarUnitYear = kCFCalendarUnitYear, 一年
NSCalendarUnitMonth = kCFCalendarUnitMonth, 一个月
NSCalendarUnitDay = kCFCalendarUnitDay, 天
NSCalendarUnitHour = kCFCalendarUnitHour, 时
NSCalendarUnitMinute = kCFCalendarUnitMinute,分
NSCalendarUnitSecond = kCFCalendarUnitSecond,秒
NSCalendarUnitWeekday = kCFCalendarUnitWeekday, 一个礼拜
NSCalendarUnitWeekdayOrdinal = kCFCalendarUnitWeekdayOrdinal,
*/
// 注册通知
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { [[UIApplication sharedApplication]registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeAlert categories:nil]];
}
not.soundName= UILocalNotificationDefaultSoundName;
// 发送通知
[[UIApplication sharedApplication]scheduleLocalNotification:not];
// UIUserNotificationTypeBadge| 圆圈内提示的数字
// UIUserNotificationTypeSound| 通知提示的声音
// UIUserNotificationTypeNone|
// UIUserNotificationTypeAlert 振动
}
IOS 本地通知的更多相关文章
- IOS 本地通知 UILocalNotification
IOS 本地通知 UILocalNotification [本文章第四部分中的代码逻辑来自网上的借鉴,并非我自己原创] 大概一个月前,我开始跟着做IOS项目了.学习C++,了解Objective-C, ...
- iOS 本地通知 操作
iOS 本地通知 操作 1:配置通知:然后退出程序: UILocalNotification *localNotif = [[UILocalNotification alloc] init]; loc ...
- IOS本地通知
发送通知: UILocalNotification *newNotification = [[UILocalNotification alloc] init]; if (newNotifica ...
- IOS本地通知:UILocalNotification使用记录
第一次接触IOS的本地通知的使用,看到别人写的一个比较详细的记录,自己整理过来,方便以后再次使用和拓展: 1.创建一个本地通知,添加到系统: // 初始化本地通知对象 UILocalNotificat ...
- xamarin.ios 本地通知推送
由于ios10版本以后UILocalNotification被标为弃用了,所以要添加新的本地通知推送功能,下面提供一些代码参考. 一.先在AppDelegate.cs上注册本地通知推送功能. publ ...
- iOS: 本地通知的前后变化(iOS10)
一.介绍 通知和推送是应用程序中很重要的组成部分.本地通知可以为应用程序注册一些定时任务,例如闹钟.定时提醒等.远程推送则更强大,提供了一种通过服务端主动推送消息到客户端的方式,服务端可以更加灵活地 ...
- IOS 本地通知推送消息
在现在的移动设备中,好多应用性的APP都用到了推送服务,但是有好多推送的内容,比如有的只是单纯的进行推送一个闹钟类型的,起了提醒作 用,有的则是推送的实质性的内容,这就分为推送的内容来区别用什么推送, ...
- iOS(本地通知与远程通知)
iOS 推送通知有两种:本地推送.远程推送. 本地推送 : 在不需要联网的情况下,由APP发出推送,常用于某一时刻的通知,如闹钟.本地通送有局限性在于当APP处于后台或者退出时就无法发出通知. 远程 ...
- IOS 本地通知UILocalNotification
//发送通知 UILocalNotification *notification=[[UILocalNotification alloc] init]; if (notificati ...
随机推荐
- 【原】Spark中Master源码分析(一)
Master作为集群的Manager,对于集群的健壮运行发挥着十分重要的作用.下面,我们一起了解一下Master是听从Client(Leader)的号召,如何管理好Worker的吧. 1.家当(静态属 ...
- 文件操作总结:关于文本和二进制流(typeText&typeBinary)
本人能力.精力有限,所言所感都基于自身的实践和有限的阅读.查阅,如有错误,欢迎拍砖,敬请赐教——博客园:钱智慧. 总结: CFile,其自身是不提供缓冲区的(?但CFile又有一个Flush,这一点目 ...
- Java笔记(二十二)……Collection集合
概述 为什么会出现集合类 面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,就对对象进行存储,集合就是存储对象最常用的一种方式 数组和集合类同是容器,有何不同 数组虽然也可以存储 ...
- 输入A和B,计算并输出A+B
EOF是一个预定义的常量,等于-1. 输入A和B,计算并输出A+B Sample input: 1 5 10 20 Sample output: 6 30 #include <iostr ...
- jqGrid 设置列宽
在jqgrid显示出来之后,需要手动调整列宽. 1. 经过调查jqgrid本身不支持指定列宽,当然这个是说的的初始化完成后. 2. 经过调查手动是可以调整列宽,所以进行了事件的查看resizestop ...
- poj 2367 Genealogical tree (拓扑排序)
火星人的血缘关系很奇怪,一个人可以有很多父亲,当然一个人也可以有很多孩子.有些时候分不清辈分会产生一些尴尬.所以写个程序来让n个人排序,长辈排在晚辈前面. 输入:N 代表n个人 1~n 接下来n行 第 ...
- PC-删除共享[绝对够狠的方法]
1.批处理清除法-------------------------------------------------------------------------------------------- ...
- 解决Debian-7.1下Chrome浏览器字体难看的问题
首先在 Advance Setting 的 font 标签页下做如下配置: 然后在用户目录下创建 .fonts.conf 文件,内容如下: <?xml version='1.0'?> &l ...
- GridControl 选择列、复选框全选(上)
说明: GirdControl 中添加一列,这一列不是写在数据库中的,而是代码中添加的. 图示: 底层类代码: #region GridControl 全选 /// <summary> / ...
- C++ 运行时类型识别 知道实例父类类型,显示出子类类型
typeid(nets_[i]).name() 其中的nets_[i]是一个对象