操作流程

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. 【解决】Oracle服务器ip地址被占用

    数据库服务器ip地址被占用,怎么破?! 服务器: 1.改服务器ip: 2.改tnsnames.ora里配置的Oracle数据库ip: 3.重启Oracle服务: 客户端: 1.改tnsnames.or ...

  2. HW3.14

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HW2.8

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. SQL Server Data Tool 嘹解(了解)一下 SSDT -摘自网络

    Visual Studio 2010 的伺服器管理員可以用來連接 Sharepoint.伺服器,還可以透過資料連接連結至 SQL Server  等資料來源.以資料來源為例,您可以利用單一工具(Vis ...

  5. CentOS搭建VSFTP

    1.先看看有没有安装 rpm -qa | grep vsftpd 如果没有提示,说明没有安装.接下来,我们安装一个ftp. 2.yum安装vsftpd: yum -y install vsftpd 安 ...

  6. 无法识别的属性“targetFramework”。请注意属性名称区分大小写。错误分析以及解决方案

    我的配置文件中是这样写的,<compilation debug="true" targetFramework="4.0"> 发布在iis上出现了 “ ...

  7. em与px之间的换算

    任意浏览器的默认字体高度16px(16像素).所有未经调整的浏览器都符合:1em=16px.那么12px=0.75em,10px=0.625em.为了简化font-size的换算,需要在css中的bo ...

  8. cocos2d-x 绘制基本图元

    转自:http://4137613.blog.51cto.com/4127613/754729 第一部分:基本图形绘制   cocos2dx封装了大量opengl函数,用于快速绘制基本图形,这些代码的 ...

  9. Tomcat 优化

    1.apr 许多朋友可能在启动tomcat的时候都会看到类似这样的信息: 引用 org.apache.catalina.core.AprLifecycleListener init 信息: The A ...

  10. 使用json-lib进行Java和JSON之间的转换

    1. json-lib是一个java类库,提供将Java对象,包括beans, maps, collections, java arrays and XML等转换成JSON,或者反向转换的功能. 2. ...