//本地推送---无需网络,由本地发起

UILocalNotification *localNotification = [[UILocalNotification alloc]init];

//设置推送时间间隔并开启推送fireDate

localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];

//设置提醒内容

localNotification.alertBody = @"注意要吃饭了";

//设置提醒标题

localNotification.alertTitle = @"提示";

//未读数图标显示badgeNumber

localNotification.applicationIconBadgeNumber = 2;

//定时推送

[[UIApplication shareApplication] scheduleLocalNotification:localNotification];

iOS8 以后需要添加如下步骤

//获取当前设备的系统版本UIDevice

if ([UIDevice currentDevice].systemVersion.floatValue > 8.0) {

UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];

//注册推送 以及 推送相关设置

[[UIApplication sharedApplication]registerUserNotificationSettings:setting];

}

//上文中设置

applicationIconBadgeNumber

在阅读完推送信息后应当清零

此时应该在AppDelegate文件中

设置

//已经收到推送信息后调用的方法

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

application.applicationIconBadgeNumber = 0;

}

本地推送UILocalNotification的更多相关文章

  1. 本地推送UILocalNotification(转)

    1.增加一个本地推送 //设置20秒之后 NSDate *date = [NSDate dateWithTimeIntervalSinceNow:]; //chuagjian一个本地推送 UILoca ...

  2. Swift - 推送之本地推送(UILocalNotification)添加Button的点击事件

    上一篇讲到的本地推送是普通的消息推送,本篇要讲一下带按钮动作的推送消息 import UIKit @UIApplicationMain class AppDelegate: UIResponder, ...

  3. Swift - 推送之本地推送(UILocalNotification)

    // 本地推送通知是通过实例化UILocalNotification实现的.要实现本地化推送可以在AppDelegate.swift中添加代码实现,本事例是一个当App进入后台时推送一条消息给用户. ...

  4. 本地推送UILocalNotification的一些简单方法

    1.添加本地推送,需要在app添加推送.可以根据通知的userInfo的不同的键值对来区分不同的通知 UILocalNotification *notification = [[UILocalNoti ...

  5. SWIFT推送之本地推送(UILocalNotification)之二带按钮的消息

    上一篇讲到的本地推送是普通的消息推送,本篇要讲一下带按钮动作的推送消息,先上个图瞅瞅: 继上一篇的内容进行小小的改动: 在didFinishLaunchingWithOptions方法内进行以下修改 ...

  6. SWIFT推送之本地推送(UILocalNotification)

    本地推送通知是通过实例化UILocalNotification实现的.要实现本地化推送可以在AppDelegate.swift中添加代码实现,本事例是一个当App进入后台时推送一条消息给用户. 1.首 ...

  7. [转载]iOS本地推送-备用

    第一步:创建本地推送// 创建一个本地推送UILocalNotification *notification = [[[UILocalNotification alloc] init] autorel ...

  8. cocos2d-x中本地推送消息

    作者:HU 转载请注明,原文链接:http://www.cnblogs.com/xioapingguo/p/4038277.html  IOS下很简单: 添加一条推送 void PushNotific ...

  9. [iOS 高级] iOS远程推送与本地推送大致流程

    本地推送: UILocalNotification *notification=[[UILocalNotification alloc] init]; if (notification!=nil) { ...

随机推荐

  1. Mac 终端命令大全

    目录操作 命令名 功能描述 使用举例 mkdir 创建一个目录 mkdir dirname rmdir 删除一个目录 rmdir dirname mvdir 移动或重命名一个目录 mvdir dir1 ...

  2. Sum All Primes

    function sumPrimes(num) { //return num; var arr = []; var ifPrime = function(num){ if(num < 2){ r ...

  3. VS2010+C#+AutoCAD2008时断点调试功能无效的处理方法

    把acad.exe.config文件修改为:------------------------------------------------------------------------------ ...

  4. jquery 清空 iframe 的内容,,iframe自适应高度

    $(iframe).contents().find("body").html(""); iframe自适应高度 $("#AllDescription& ...

  5. 如何去掉Eclipse里面自动追加的一些注释!!!内详

    比如我创建一个类,勾选了自动生成main函数.他就来一个// TODO Auto-generated method stub比如我输入"try"然后自动补完try catch bl ...

  6. 【转】如何理解c和c++的复杂类型声明

    转自:http://blog.chinaunix.net/space.php?uid=22889411&do=blog&id=59667 曾经碰到过让你迷惑不解.类似于int * (* ...

  7. Regular Expression Matching leetcode

    递归方法运行时间过长.考虑使用动态规划的方法. 代码如下: bool isMatch(string s, string p) { int i,j; int m=s.size(); int n=p.si ...

  8. 使用spring的特殊bean完成配置

    1.分散配置 beans.xml配置如下: 使用占位符变量代替bean装配文件中的硬编码配置.占位符采用${variable}形式. 说明:当通过context:property-placeholde ...

  9. BOOTSTRAP定制

    1.补充:栅格系统中调整列的位置/顺序 (1)方法1:偏移量(col-*-offset-*) (2)方法2:对列进行push/pull操作 col-lg-pull-1        ~         ...

  10. dom4j使用xpath报异常 Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/NamespaceContext

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/NamespaceContext      ...