操作流程

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. org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text

    代码缺少这一行:job.setInputFormatClass(KeyValueTextInputFormat.class);

  2. 非递归实现先序遍历 java leecode 提交

    写完才知道自己学习都是似是而非啊,大家可以也在leecode上提交代码,纯手写,离开eclipse第一种方式:数据结构书上的,使用栈大概思路.1.不断将根节点的左孩子的左孩子直到为空,在这个过程入栈. ...

  3. (转载)Excel文档保存的时候,提示“文档未保存”

    亲测,成功搞定 Excel文档保存的时候,提示“文档未保存”? 先打开你需要处理的excel,然后打开工具栏--宏--录制新宏--确定--停止录制宏--宏-宏--编辑--复制以下程序Sub 恢复保存( ...

  4. 【Java基础】Integer包装类的缓冲池问题

    首先看下面这个例子: public class TestNew { public static void main(String args[]){ Integer i1 = 10; //Integer ...

  5. Mac中下载JDK手动更新出现“只支持10.7.3以上的系统版本”问题解决方案

    今天倒腾Hadoop,要修改源码,由于之前搞研究是基于hadoop1.0.3来做的,所以这次也用的这个版本,但是我电脑上Java的版本是1.8以上的,结果用ant编译hadoop源码报错,错误大概是这 ...

  6. [Windows Server] 在 Windows Server 2012 上安裝 .NET Framework 3.5 - 摘自网络

    官方: Applies To: Windows 8, Windows 8.1 For a Windows Server® 2012 core installation that is not conn ...

  7. CodeForces 540E - Gerald and Giant Chess(数论)

    给一个棋盘,需要从左上角走到右下角,有部分点不能走,求一共有多少种走法. 首先要知道从一个点A到另一个点B在没有障碍下有多少种走法.保证A在B的左上方,如图 一共需要走(X+Y)步(图中△x,△y), ...

  8. hdu5601-N*M bulbs(黑白棋盘染色)

    一个矩形,一个人从左上角走到右下角,每走过一个位置把0变成1,1变成0. 求有没有可能他离开之后所有的数都是0 假设这个矩形是一个棋盘,黑白相间. 这样会发现从一个颜色走到相同颜色可以对棋盘不产生任何 ...

  9. CodeForces Round #179 (295A) - Greg and Array

    题目链接:http://codeforces.com/problemset/problem/295/A 我的做法,两次线段树 #include <cstdio> #include < ...

  10. storm核心组件

    Storm核心组件 了解 Storm 的核心组件对于理解 Storm 原理非常重要,下面介绍 Storm 的整体,然后介绍 Storm 的核心. Storm 集群由一个主节点和多个工作节点组成.主节点 ...