UILocalNotification本地通知
// 执行通知一定要退出应用或挂起应用(进入后台)才能收到通知。
// 创建本地通知
UILocalNotification *notification = [[UILocalNotification alloc] init];
// 通知触发时间
// 5秒钟之后触发 notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
// 通知时区
// 使用本地时区 notification.timeZone = [NSTimeZone defaultTimeZone];
// 通知提示内容
notification.alertBody = @"顶部提示内容,您有有一个通知";
// 通知提示音
//使用默认的通知提示音 notification.soundName = UILocalNotificationDefaultSoundName;
// 应用程序右上角显示的数字
notification.applicationIconBadgeNumber = 1;
// 数据字典
notification.userInfo = @{@"userName": @"小明", @"age": @(18)};
// 启动这个通知
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
// 进入前台,清除右上角图标
- (void)applicationWillEnterForeground:(UIApplication *)application {[application setApplicationIconBadgeNumber:0]; }
// 点顶端通知进入应用
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"标题" message:notification.userInfo[@"userName"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];[alert show]; }
// 清除当前应用所有通知
[[UIApplication sharedApplication] cancelAllLocalNotifications];
转载于:https://www.cnblogs.com/limengdev/p/UILocalNotification.html
UILocalNotification本地通知相关推荐
- iOS开发之本地通知UILocalNotification
本地通知是UILocalNotification的实例,主要有三类属性: scheduled time:时间周期,用来指定iOS系统发送通知的日期和时间: notification type:通知类型 ...
- iOS开发---本地通知(UILocalNotification)
iOS中通知机制又叫消息机制,其包括两类:一类是本地通知:另一类是推送通知,也叫远程通知. 本地通知是由本地应用触发的,它是基于时间行为的一种通知形式,例如闹钟定时.待办事项提醒,又或者一个应用在一段 ...
- 【iOS开发-119】ipa打包、单元测试test、本地通知UILocalNotification
(1)ipa打包,可以用Xcode,也可以用iTunes,用后者比较快. 具体教程:使用XCode和iTunes打包ipa i OS_ipa打包的方法 (2)单元测试(一般用于测试某一个方法是否可行等 ...
- iOS实现本地通知(local notification)的方法
iOS 的本地通知(local notification)用于基于时间行为的通知,比如有关日历或者 todo 列表的小应用.另外应用如果在后台执行,iOS 允许它在受限的时间内运 行,它也会发现本地通 ...
- iOS 远程通知(Remote Notification)和本地通知(Local Notification)
ios通知分为远程通知和本地通知,远程通知需要连接网络,本地通知是不需要的,不管用户是打开应用还是关闭应用,我们的通知都会发出,并被客户端收到 我们使用远程通知主要是随时更新最新的数据给用户,使用本地 ...
- iOS 本地通知 操作
iOS 本地通知 操作 1:配置通知:然后退出程序: UILocalNotification *localNotif = [[UILocalNotification alloc] init]; loc ...
- [原]逆向iOS SDK -- “添加本地通知”的流程分析
观点: 代码面前没有秘密 添加通知的 Demo 代码 - (void)scheduleOneLocalNotification { [[UIApplication sharedApplication] ...
- iOS监听模式系列之本地通知Notification
本地通知 本地通知是由本地应用触发的,它是基于时间行为的一种通知形式,例如闹钟定时.待办事项提醒,又或者一个应用在一段时候后不使用通常会提示用户使用此应用等都是本地通知.创建一个本地通知通常分为以下几 ...
- 注册本地通知【闹钟,备忘录】
// -------------------注册本地通知-----------------// 创建一个本地通知对象UILocalNotification *localNotification = [ ...
最新文章
- pythonwin32api拖动图标_Python使用win32api,模拟鼠标移动并复制/粘贴到diskfi中
- 分布与并行计算—日志挖掘(Java)
- ​​2021快手母婴行业数据价值报告
- 2021-08-20 Redis 基本类型:string set sortedSet Hash List
- Matlab toolbox Manopt流形优化工具包介绍
- java毕向东helloworld_毕向东java基础课学习笔记2——Hello world
- 最简单的文件加密工具(完全免费)
- 电子系统设计实践——软件编写
- 差别-request.getParameterValues与request.getParameter
- selenium+java+chrome环境搭建
- 七个习惯之四:双赢思维
- 解决mosh: Nothing received from server on UDP port 60001 环境: centos7.1
- h3cmsr830series说明书_H3C MSR830路由器设置
- 信号完整性之铜皮粗糙度
- 单页面网站的优化方法大全
- hist seg, find peaks, tps, pava单调拟合, isotonic-regression,REGULARIZED DISCRETE OPTIMAL TRANSPORT
- (附源码)springboot社区养老医疗服务平台 毕业设计 041148
- Python AQI空气污染指数数据分析与机器学习
- 为什么 K8s 在阿里能成功?
- 数据挖掘 | 航空公司客户流失预测
热门文章
- linux有关网络服务的接口,linux系统有关网络服务接口定义是哪个?
- docker 安装mysql实战_使用docker搭建mysql实例教程
- oracle如何避免表锁定,Oracle 解决表锁定的问题
- 连接mysql次数_MySQL通过CONNECTION_CONTROL限制连接次数
- python计算每月工资多少钱_[Python]CCF——工资计算(201612-2)
- 操作系统存储器管理实验报告_献上膝盖!华为工程师抛出一份堪称“举世无双”操作系统笔记...
- profile matlab,使用profile功能对Matlab性能调优
- html不继承父级背景色,javascript – 如何获取从父元素继承的计算背景颜色样式...
- python adb模块_python中adb有什么功能
- html+radio设置背景图片,jquery – 用单选按钮更改背景图像