操作流程

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 本地通知的更多相关文章

  1. IOS 本地通知 UILocalNotification

    IOS 本地通知 UILocalNotification [本文章第四部分中的代码逻辑来自网上的借鉴,并非我自己原创] 大概一个月前,我开始跟着做IOS项目了.学习C++,了解Objective-C, ...

  2. iOS 本地通知 操作

    iOS 本地通知 操作 1:配置通知:然后退出程序: UILocalNotification *localNotif = [[UILocalNotification alloc] init]; loc ...

  3. IOS本地通知

        发送通知: UILocalNotification *newNotification = [[UILocalNotification alloc] init]; if (newNotifica ...

  4. IOS本地通知:UILocalNotification使用记录

    第一次接触IOS的本地通知的使用,看到别人写的一个比较详细的记录,自己整理过来,方便以后再次使用和拓展: 1.创建一个本地通知,添加到系统: // 初始化本地通知对象 UILocalNotificat ...

  5. xamarin.ios 本地通知推送

    由于ios10版本以后UILocalNotification被标为弃用了,所以要添加新的本地通知推送功能,下面提供一些代码参考. 一.先在AppDelegate.cs上注册本地通知推送功能. publ ...

  6. iOS: 本地通知的前后变化(iOS10)

    一.介绍  通知和推送是应用程序中很重要的组成部分.本地通知可以为应用程序注册一些定时任务,例如闹钟.定时提醒等.远程推送则更强大,提供了一种通过服务端主动推送消息到客户端的方式,服务端可以更加灵活地 ...

  7. IOS 本地通知推送消息

    在现在的移动设备中,好多应用性的APP都用到了推送服务,但是有好多推送的内容,比如有的只是单纯的进行推送一个闹钟类型的,起了提醒作 用,有的则是推送的实质性的内容,这就分为推送的内容来区别用什么推送, ...

  8. iOS(本地通知与远程通知)

    iOS 推送通知有两种:本地推送.远程推送. 本地推送 :  在不需要联网的情况下,由APP发出推送,常用于某一时刻的通知,如闹钟.本地通送有局限性在于当APP处于后台或者退出时就无法发出通知. 远程 ...

  9. IOS 本地通知UILocalNotification

    //发送通知    UILocalNotification *notification=[[UILocalNotification alloc] init];       if (notificati ...

随机推荐

  1. [CODEVS1216]跳马问题

    题目描述 Description 题目 输入描述 Input Description 第一行两个正整数M,N(0<M,N≤300)分别表示行和列 第二行两个正整数,表示起点的行列坐标. 第三行两 ...

  2. VS2013 MVC Web项目使用内置的IISExpress支持局域网内部机器(手机、PC)访问、调试

    VS2013内置了IISExpress.做asp.net MVC的web项目开发时,Ctrl+F5和F5启动项目运行(后者是调试模式)的同时都会打开IISExpress,事实上本机对该web项目走的就 ...

  3. AIX 添加开机启动项

    在学习本主题之前,还是先学习一些AIX关于启动的基础知识,如果你只关心如何开机自动重启程序,请跳过第一章.第二章. ----------------------------第一章 AIX开机启动过程介 ...

  4. bzoj 1880 [Sdoi2009]Elaxia的路线(最短路+拓扑序)

    Description 最近,Elaxia和w**的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们 必须合理地安排两个人在一起的时间.Elaxia和w**每天都要奔波于宿舍和实验室之间, ...

  5. CodeForces 362B Petya and Staircases

    题意:一个小男孩要上楼梯,他一次可以走1个台阶或2个台阶或3个台阶,但是有一些台阶是脏的,他不想走在脏台阶上.一共有n个台阶和m个脏台阶,他最开始在第1个台阶上,要走到第n个台阶.问小男孩能不能不踩到 ...

  6. 三种情形容易引起Azure虚拟机重新启动

      与虚拟机或云服务角色中运行的代码有关的问题可能会导致重新启动.但是,Microsoft 在以下情况下也会重新启动您的角色: 来宾操作系统更新 – 仅影响云服务 Web 和辅助角色.有关如何限制这些 ...

  7. [E120L][KitKat][4.4.2][CM11] CM11 rom+ google app安装心得

    1. 本文针对 三星手机型号: E120L  即 samsung galaxy S2 HD LTE 2. 本文安装的android ROM 的内核为4.4.2 KitKat 3. 本文安装的第三方RO ...

  8. android图片闪烁或帧动画

    remote_recording_transition.xml 文件 <?xml version="1.0" encoding="utf-8"?> ...

  9. 8-18-Exercise

    8-18-小练 A.HDU 1172   猜数字 采用枚举~[赤果果的暴力~] 代码: #include <iostream> #include <cstdio> #inclu ...

  10. Ⅷ.spring的点点滴滴--抽象对象和子对象

    承接上文 抽象对象和子对象 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { public string Name { get; ...