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 ...
随机推荐
- [POJ2348]Euclid's Game
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8313 Accepted: 3374 Description Two p ...
- bss段为什么要初始化,清除
我们都知道bss段需要初始化,但是这是为什么呢? 通过浏览资料,我们都会发现,bss段是不会出现在程序下载文件(*.bin *.hex)中的,因为全都是0.如果把它们出现在程序下载文件中,会增加程序下 ...
- 全面产品管理-从细微处认识"用户体验"
转载: 让我以一个故事开始本文,我觉得这个故事能概括大多数人听到“用户体验”这个术语时的想法. 我经常访问的一个财经网站给我发了一封电子邮件,请求我点击里面的一个链接,对一些信息进行审核.所以我就点了 ...
- Esper系列(九)NamedWindow语法create、Insert、select
功能:用于存储一种或多种类型的事件的集合,并能对所存储的事件进行增删改查操作. CreateNameWindow 根据已有的数据源构造 格式: 1 [context context_name] 2 ...
- Log Parser 微软强大的日志分析工具
Log Parser(微软网站下载)是微软公司出品的日志分析工具,它功能强大,使用简单,可以分析基于文本的日志文件.XML 文件.CSV(逗号分隔符)文件,以及操作系统的事件日志.注册表.文件系统.A ...
- yuv 图像里的stride和plane的解释
stride可以翻译为:跨距 stride指在内存中每行像素所占的空间.如下图所示,为了实现内存对齐(或者其它的什么原因),每行像素在内存中所占的空间并不是图像的宽度. plane一般是以luma p ...
- mac os的android开发国内库下载地址
http://ubuntu.buct.edu.cn/android/repository/
- C# WinForm修改Panel边框颜色
private void panel1_Paint(object sender, PaintEventArgs e) { ControlPaint.DrawBorder(e.Graphics, thi ...
- iOS开发:UIImageView常用操作
UIImageView,顾名思义,是用来放置图片的.使用Interface Builder设计界面时,当然可以直接将控件拖进去并设置相关属性,这就不说了,这里讲的是用代码. 1.创建一个UIImage ...
- IOS - view之间切换
//进入下一页 - (IBAction)Go:(id)sender { TwoViewController *twoVC = [[TwoViewController alloc] init];//这里 ...