操作流程

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  振动

}

最新文章

  1. $this-->name
  2. 永久解决火狐浏览器出现的flash版本更新问题
  3. AMD GPU spec (public)
  4. the OS maintains a number of queues
  5. opencv通过dll调用matlab函数,图片作为参数
  6. MSP430F149学习之路——UART
  7. 分享个新浪下载图片的ProgressBar进度样式
  8. C++模板实例化(1)
  9. javascript权威指南(中文版)中的一些错误(一)
  10. 读取Log日志并打印到sdcard
  11. 世界最大射电望远镜(Arecibo)用于探測地外文明
  12. poj 2186 (强连通缩点)
  13. [原创]nagios搭建配置
  14. Git使用教程及常用命令大全
  15. Zepto中的Swipe事件失效
  16. 轻量级网络库libevent概况
  17. js深度复制三种方法
  18. jenkins备份与恢复【转】
  19. verilog reg 初值问题
  20. C++中的字符串输入输出函数详解

热门文章

  1. AABB碰撞盒
  2. eclipse中 将java项目转换为web项目 博客分类: Tomcat
  3. Python队列服务 Python RQ Functions from the __main__ module cannot be processed by workers.
  4. Powerdesigner设置表结构对齐方式
  5. 用Natvis定制C++对象在Visual Studio调试时如何显示
  6. 通过Mouse Without Borders在多台机器上共享键盘鼠标
  7. iOS_icon命名规范 (iPhone_retina屏幕开发)
  8. Shiro 源码分析
  9. [转]把项目从VS2005升级到VS2013
  10. Android 自定义View修炼-仿QQ5.0 的侧滑菜单效果的实现