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

localNotification.alertBody = @"this is a local notification";

localNotification.soundName = UILocalNotificationDefaultSoundName;

//schedule the time to push local notification

NSCalendar* calendar = [NSCalendar autoupdatingCurrentCalendar];

NSDate* currentDate = [NSDate date];

NSDateComponents* currentDateComponents = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate:currentDate];

NSDateComponents* scheduledDateComponents = currentDateComponents;

if (currentDateComponents != nil) {

[scheduledDateComponents setDay:currentDateComponents.day + 7];

[scheduledDateComponents setHour:17];

[scheduledDateComponents setMinute:0];

[scheduledDateComponents setSecond:0];

}

NSDate* scheduledDate = [calendar dateFromComponents:scheduledDateComponents];

localNotification.fireDate = scheduledDate;

[[UIApplication sharedApplication]cancelAllLocalNotifications];

[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];

/////SIMPLE WAY

http://stackoverflow.com/questions/10060578/uilocalnotification-fires-immediately-instead-of-at-scheduled-time

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];
localNotification.alertBody = @"Your alert message";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

ios push local notification的更多相关文章

  1. iOS 远程通知(Remote Notification)和本地通知(Local Notification)

    ios通知分为远程通知和本地通知,远程通知需要连接网络,本地通知是不需要的,不管用户是打开应用还是关闭应用,我们的通知都会发出,并被客户端收到 我们使用远程通知主要是随时更新最新的数据给用户,使用本地 ...

  2. iOS - Push 通知推送

    1.UserNotifications 通知是 App 用来和用户交流的一种方式,特别是当 App 并没有在前台运行的时候.通知,正如它的名称所强调的,被用作向用户'通知'一个事件,或者仅仅向用户提示 ...

  3. iOS Push详述,了解一下?

    WeTest 导读 本文主要对iOS Push的在线push.本地push及离线(远程)push进行梳理,介绍了相关逻辑,测试时要注意的要点以及相关工具.小小的Push背后蕴藏着大大的逻辑! Push ...

  4. 了解iOS消息推送一文就够:史上最全iOS Push技术详解

    本文作者:陈裕发, 腾讯系统测试工程师,由腾讯WeTest整理发表. 1.引言 开发iOS系统中的Push推送,通常有以下3种情况: 1)在线Push:比如QQ.微信等IM界面处于前台时,聊天消息和指 ...

  5. 苹果推送(APNs)ios push小结

    把app删除后就推送不成功了,可以看出deviceToken应该是设备+app来一起识别的,重新安装后仍然为同一个 简介 推送服务APNs(Apple Push Notification servic ...

  6. IOS PUSH 实践操作~~~~

    1.推送过程简介        (1)App启动过程中,使用UIApplication::registerForRemoteNotificationTypes函数与苹果的APNS服务器通信,发出注册远 ...

  7. iOS push全方位解析(二)【译文】"——生成OpenSSL证书,Provisioning Profile

    这是一篇来自raywenderlich的教程,内容翔实!结构简单透彻.讲解循序渐进.文章质量上乘!是一篇难的的博文!使用半瓶的英语水平翻译了一下: 1.[iOS push全方位解析](一) push的 ...

  8. Local Notification

    大家都知道Push Notification,这个东西需要联网才可以用.iOS4起,苹果引入了一种可以在设备内部引发的notification.不需要复杂的服务器编程,或其他复杂的配置.这个技术就是L ...

  9. iOS push过去的时候界面不能完全退出

    iOS push过去的时候界面不能完全退出 解决方法:设置self.view.backgroundcolor 1. initWithFrame方法是什么?  initWithFrame方法用来初始化并 ...

随机推荐

  1. VPC/VM/VBOX安装GHOST版的无法启动系统

    本人最近在安装一些公司的虚拟机,方便开发使用,不用每次都安装几个小时的装机和安装软件,但是本次却遇到了一点问题,虚拟机安装完成后一直无法进入系统,只有一个光标在黑色的屏幕上一闪一闪的,也没有任何错误提 ...

  2. MSDN Windows XP Professional x64 Edition with SP2 +VL简体中文语言包+序列号

    [资源名称]---Windows XP Professional x64 Edition with SP2 - VL (English)[资源类型]---ISO镜像[资源语言]---英语+简体中文[杀 ...

  3. ereg()替换为preg_match(),ereg_repalce替换为preg_replace得加斜杠

    PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”是因为它长ereg 函数进行了升级处理,需要像preg_match使用/ /来 ...

  4. [LeetCode系列] 双单链表共同节点搜索问题

    找到两个单链表的共同节点. 举例来说, 下面两个链表A和B: A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3 共同节点为c1. 分析: 共同节点距离A,B的起点 ...

  5. FormData 知识点

    通过FormData对象可以组装一组用 XMLHttpRequest发送请求的键/值对.它可以更灵活方便的发送表单数据,因此可以独立于表单使用. 如果你把表单的编码类型设置为multipart/for ...

  6. 未能正确加载“VSTS for Database Professionals Sql Server Data-tier Application”包。(转)

    今天费了九牛二虎之力,重转好了vs2010之后,打开解决方案,报出下面的错误: ---------------------------Microsoft Visual Studio---------- ...

  7. js区分大小写

    JavaScript 区分大小写 区分大小写 JavaScript 语言是区分大小写的,不管是命名变量还是使用关键字的时候. 如前面 alert弹出提示框 的例子,如果将 alert 命令改为 ALE ...

  8. 学习笔记之XML

    什么是QName - Benjieming_Wang的专栏 - CSDN博客 http://blog.csdn.net/Benjieming_Wang/article/details/5959961 ...

  9. 尽量少嵌套无用的div;外部文件尽量使用link而不要使用用@import

    最近的工作又学到了很多东西,在这里记录一下. 1,尽量少嵌套无用的div,这个问题领导很严肃的跟我提过很多次,因为我很喜欢用很多div,而且有很多div都是无存在意义的.后来领导给了我一些资料,我看了 ...

  10. mono部分源码解析

    一.源码结构 这里仅列举几个重要的目录:mcs:    mcs: Mono实现的基于Ecma标准的C#编译器.    class: CLI的C#级的实现.类似于Android中的Java层,应用程序看 ...