当前位置: 首页 > news >正文

本地通知UILocalNotification

/*

 本地通知(UILocalNotification)  操作流程:

 1、接收通知

 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

 

 //     接收到通知 之后的操作

 

 }

 

 2、注册 发送通知(需注意iOS8 之后的改动)

 提示事件

 闹钟

 

 

 */

 

 

#import "ViewController.h"

 

 

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

 

 

}

 

//- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//    

//    [self pushNotifation];

//

//    return YES;

//}

 

//

    接收本地通知

//- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

//    

    接收到通知 之后的操作

//    NSLog(@"接收到通知 之后 %@", notification.userInfo);

//    

//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:notification.alertTitle message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//    [alert show];

//    

//}

//

//

//- (void)pushNotifation {

//    

  注册 发送通知

//    /**

//     初始化本地通知方法

//     */

//    UILocalNotification *not = [[UILocalNotification alloc] init];

    启动的时间  fireDate

    TimeInterval 时间单位是 秒

//    not.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];

    设置通知标题

//    not.alertTitle= @"时间到";

    设置通知的 内容

//    not.alertBody = @"该起床了,太阳都晒到屁股了";

    通过通知 传递内容

//    not.userInfo = @{@"key":@"send infomation"};

    设置 app 图标上面的“红点显示的”数字

//    not.applicationIconBadgeNumber = 1;

//    

//    

//    /*

//     NSCalendarUnitEra                = kCFCalendarUnitEra,一个世纪

//     NSCalendarUnitYear               = kCFCalendarUnitYear, 一年

//     NSCalendarUnitMonth              = kCFCalendarUnitMonth, 一个月

//     NSCalendarUnitDay                = kCFCalendarUnitDay, 天

//     NSCalendarUnitHour               = kCFCalendarUnitHour, 时

//     NSCalendarUnitMinute             = kCFCalendarUnitMinute,分

//     NSCalendarUnitSecond             = kCFCalendarUnitSecond,秒

//     NSCalendarUnitWeekday            = kCFCalendarUnitWeekday, 一个礼拜

//     NSCalendarUnitWeekdayOrdinal     = kCFCalendarUnitWeekdayOrdinal,

//     */

//    not.repeatInterval = kCFCalendarUnitDay;    //  一天提示一次

//    

    注册通知

    判断是否可以相应 某个方法

    [self respondsToSelector:<#(SEL)#>];

//  

//    /*

//     UIUserNotificationTypeNone

//     UIUserNotificationTypeBadge 圆圈内提示的数字

//     UIUserNotificationTypeSound  通知提示的声音

//     UIUserNotificationTypeAlert   振动

//     */

//    if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {

//        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeNone |

//                                                                            UIUserNotificationTypeBadge |

//                                                                             UIUserNotificationTypeSound |

//                                                                            UIUserNotificationTypeAlert  categories:nil]];

//    }

//    not.soundName = UILocalNotificationDefaultSoundName;

//    

//    

    发送通知

//    [[UIApplication sharedApplication] scheduleLocalNotification:not];

//

//    

//    

//}

 

转载于:https://www.cnblogs.com/wukun16/p/4884159.html

相关文章:

  • centos下/etc/sysconfig/下找不到iptables文件
  • ifconfig命令
  • S3C2440-LCD字符显示
  • 链表与哈希表基本概念及Java常用集合
  • 大脑的美食
  • (算法)Travel Information Center
  • 带进度条的文件批量上传插件uploadify
  • Bootstrap 下拉菜单
  • jQuery的Ajax提交
  • linux命令ps aux|grep xxx详解
  • EXCEL数据导入SQL表的方法
  • 研究:我们的宇宙至少四次进入其它宇宙
  • js获取元素样式
  • Adobe:下一代Flash Player效率将提高10倍
  • 九度OJ 1054:字符串内排序 (排序)
  • axios请求、和返回数据拦截,统一请求报错提示_012
  • canvas 五子棋游戏
  • co模块的前端实现
  • Vue官网教程学习过程中值得记录的一些事情
  • 从输入URL到页面加载发生了什么
  • 大型网站性能监测、分析与优化常见问题QA
  • 极限编程 (Extreme Programming) - 发布计划 (Release Planning)
  • 今年的LC3大会没了?
  • 聊聊flink的TableFactory
  • 前端每日实战 2018 年 7 月份项目汇总(共 29 个项目)
  • 如何使用Mybatis第三方插件--PageHelper实现分页操作
  • 一道闭包题引发的思考
  • 原创:新手布局福音!微信小程序使用flex的一些基础样式属性(一)
  • 基于django的视频点播网站开发-step3-注册登录功能 ...
  • ​DB-Engines 12月数据库排名: PostgreSQL有望获得「2020年度数据库」荣誉?
  • ​LeetCode解法汇总2696. 删除子串后的字符串最小长度
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • #define,static,const,三种常量的区别
  • #Lua:Lua调用C++生成的DLL库
  • #前后端分离# 头条发布系统
  • $ git push -u origin master 推送到远程库出错
  • (Matalb时序预测)PSO-BP粒子群算法优化BP神经网络的多维时序回归预测
  • (Matlab)遗传算法优化的BP神经网络实现回归预测
  • (附源码)springboot 基于HTML5的个人网页的网站设计与实现 毕业设计 031623
  • (附源码)计算机毕业设计ssm基于B_S的汽车售后服务管理系统
  • (没学懂,待填坑)【动态规划】数位动态规划
  • (强烈推荐)移动端音视频从零到上手(下)
  • (十) 初识 Docker file
  • (十)T检验-第一部分
  • (图)IntelliTrace Tools 跟踪云端程序
  • (转) Android中ViewStub组件使用
  • (转)iOS字体
  • (转)socket Aio demo
  • ./configure,make,make install的作用(转)
  • .net core 6 集成 elasticsearch 并 使用分词器
  • .NET Core Web APi类库如何内嵌运行?
  • .NET 反射 Reflect
  • .net反编译的九款神器
  • .sdf和.msp文件读取
  • /usr/bin/env: node: No such file or directory