Scheduling the Delivery of Local Notifications

Notifications are a way for an app that is suspended, is in the background, or is not running to get the user’s attention. 本地消息主要用于获得用户注意,可见方式有显示alert,播放声音,更新app icon的图表(显示一个数字)

Apps can use local notifications to display alerts, play sounds, badge the app’s icon, or a combination of the three. For example, an alarm clock app might use local notifications to play an alarm sound and display an alert to disable the alarm. 最典型的就是闹钟程序,播放声音,弹出警告框。When a notification is delivered to the user, the user must decide if the information warrants bringing the app back to the foreground. 用户可以决定是否把APP激活到前台,(If the app is already running in the foreground, local notifications are delivered quietly to the app and not to the user.)如果app本来在运行,消息会悄悄地发送到程序,而不是用户。

这悄悄地发给程序了,程序使用delegate’s application:didReceiveLocalNotification: 来接收到消息,也可以采取同样的行为,例如alert/播放sound

shows an example that schedules a single alarm using a date and time that is set by the user. This example configures only one alarm at a time and cancels the previous alarm before scheduling a new one. (Your own apps can have no more than 128 local notifications active at any given time, any of which can be configured to repeat at a specified interval.) The alarm itself consists of an alert box and a sound file that is played if the app is not running or is in the background when the alarm fires.

- (void)scheduleAlarmForDate:(NSDate*)theDate
{
    UIApplication* app = [UIApplication sharedApplication];
    NSArray*    oldNotifications = [app scheduledLocalNotifications];
 
    // Clear out the old notification before scheduling a new one.
    if ([oldNotifications count] > 0)
        [app cancelAllLocalNotifications];
 
    // Create a new notification.
    UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
    if (alarm)
    {
        alarm.fireDate = theDate;
        alarm.timeZone = [NSTimeZone defaultTimeZone];
        alarm.repeatInterval = 0;
        alarm.soundName = @"alarmsound.caf";
        alarm.alertBody = @"Time to wake up!";
 
        [app scheduleLocalNotification:alarm];
    }
}

比较贴近的:

Newsstand apps that need to download and process new content 内容杂志型的 app,需要下载和处理新内容的

Apps that receive regular updates from external accessories。经常受到外部设备的更新。。。。。。。。。

增加info配置,申明app后台一直执行长时间任务:XX-Info.plist-》UIBackgroundModes -》数组的item增加newsstand-content

  • newsstand-content—The app is a Newsstand app that downloads and processes magazine or newspaper content in the background.

  • external-accessory—The app works with a hardware accessory that needs to deliver updates on a regular schedule through the External Accessory framework.

以上的配置会使ios明白在合适的时间启动,响应相关的事件。例如播放声音的程序,在后台需要填充audio输出的buffers。

Each of the preceding values lets the system know that your app should be woken up at appropriate times to respond to relevant events. For example, an app that begins playing music and then moves to the background still needs execution time to fill the audio output buffers. Including the  audio key tells the system frameworks that they should continue playing and make the necessary callbacks to the app at appropriate intervals. 通过在info配置中加入audio,就使得系统定期通知app,app可以得到cpu事件,获取audio file内容。If the app does not include this key, any audio being played by the app stops when the app moves to the background.

Downloading Newsstand Content in the Background 通过后台下载内容

A Newsstand app that downloads new magazine or newspaper issues can register to perform those downloads in the background. When your server sends a push notification to indicate that a new issue is available, the system checks to see whether your app has the UIBackgroundModes key with the newsstand-content value. If it does, the system launches your app, if it is not already running, so that it can initiate the downloading of the new issue.

当你的远端服务器发送通知,告知程序新杂志到达时候,系统可以检查程序是否有newsstand-content 设置,如果有,系统会启动app(如果还没有运行的话),然后就会启动下载

When you use the Newsstand Kit framework to initiate a download, the system handles the download process for your app. 如g国使用NK框架初始化下载,The system continues to download the file even if your app is suspended or terminated 系统会负责下载内容的,即使app不在active. When the download operation is complete, the system transfers the file to your app sandbox and notifies your app(下载完成后,系统会接触你程序的sandbox,通知程序可以获得文件了). If the app is not running, this notification wakes it up and gives it a chance to process the newly downloaded file. 程序会被系统唤醒来处理这个通知,如果下载过程中有错误,系统也会通知程序处理此类错误If there are errors during the download process, your app is similarly woken up to handle them.

For information about how to download content using the Newsstand Kit framework, see Newsstand Kit Framework Reference.

其实目前来看,一个书架,上面有一些本地PDF,但还是要看发布者那边,如果有新的书,你可以接收下载(当然是通过NKF),这个story+PDF 编辑才能形成一个好的体验。

potential question,一体化的应用,第一财经为啥不这么干呢。。。。

参考:

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW28

background and notification of local相关推荐

  1. ios注销所有通知_您一直想了解的有关iOS中通知的所有信息

    ios注销所有通知 by Payal Gupta 通过Payal Gupta 您一直想了解的有关iOS中通知的所有信息 (Everything you've always wanted to know ...

  2. 苹果推送通知服务(APNs)编程(转)详细步骤

    iPhone 对于应用程序在后台运行有诸多限制(除非你越狱).因此,当用户切换到其他程序后,原先的程序无法保持运行状态.对于那些需要保持持续连接状态的应用程序(比如社区网络应用),将不能收到实时的信息 ...

  3. 极光API推送 (v3 版本)

    Push API v3 这是 Push API 最近的版本. 相比于 API v2 版本,v3 版本的改进为: 完全基于 https,不再提供 http 访问: 使用 HTTP Basic Authe ...

  4. PXE BOOT DIY自己的网络启动工具集合

    大家对深山红叶,矮人DOS工具箱之类的维护光盘应该不陌生了,作为企业,网吧网管,随手准备这样的光盘真的是能解决很多问题.对于网刻,相信很多人也有所了解.但是,在网吧/公司维护机器时.基本上面对的都是无 ...

  5. 20、磁贴和磁贴通知(tile)(上)

    win8 中的磁铁操作要比 windows phone 中的复杂一些,不过原理大同小异,都是一些固定内容模型. 参考文档: 磁贴和磁贴通知 : http://msdn.microsoft.com/zh ...

  6. msf与cs互相传动

    CS->MSF MSF: use exploit/multi/handler set payload windows/meterpreter/reverse_http CS: 创建监听器wind ...

  7. 重新想象 Windows 8 Store Apps (4) - 控件之提示控件: ProgressRing; 范围控件: ProgressBar, Slider...

    重新想象 Windows 8 Store Apps (4) - 控件之提示控件: ProgressRing; 范围控件: ProgressBar, Slider 原文:重新想象 Windows 8 S ...

  8. WPF 透明窗口在桌面上放虫子。。。

    抖音上偶然看到这个,咱也想来一个,看看效果: 实现很简单,一个透明窗口,一个gif图片,不显示任务栏,再加上鼠标穿透,就ok了了 看看代码: Mainwindow.xaml: <Window x ...

  9. 《深入浅出WPF》笔记——绑定篇(一)

    上一节,有记录写到:在WPF里,数据驱动UI,数据占核心地位,UI次之.怎么恢复数据的核心地位,那就要先了解一下Binding. 一.Binding 基础 1.1WPF中Data Binding的带来 ...

最新文章

  1. python爬虫教程视频-13天搞定Python分布爬虫
  2. 批量插入使用SqlBulkCopy
  3. delete后加 limit是个好习惯么 ?
  4. angular接口传参
  5. 促进新一代人工智能产业发展三年行动计划_工信部新一代人工智能产业创新重点揭榜任务——中国联通智能化网络基础设施及开放平台启动会成功召开...
  6. 带有AWS DynamoDB的反应式Spring Webflux
  7. java rpg项目代码_java rpg游戏代码(移动保存读取)
  8. C++工作笔记-对const_cast的理解
  9. @Autowired @Primary @Qualifier
  10. CSS3实现垂直居中
  11. LNMP详解(十六)——Nginx日志切割
  12. 获取MOSS页面中控件使用的样式(转)
  13. 数字信号处理教程第五版答案
  14. c 开发android原生程序,Android原生开发极简教程
  15. php webp格式转换,webp的格式的转换
  16. 文本换行符/空格符怎么在HTML中进行转换?
  17. Intriguing Properties of Vision Transformers论文解析
  18. 交通期刊JCR(2020)
  19. excel单元格内容拆分_拆分单元格内容,表哥表妹不要哭
  20. MySql报错:unblock with mysqladmin flush-hosts

热门文章

  1. HTTP请求方法之options请求
  2. 湖北电信天邑TY1608_S905L3B_MT7668_卡刷固件包
  3. 数据库的视图(View)
  4. laravel入门教程
  5. 创业公司做数据分析(二)运营数据系统
  6. 编译原理 - 词法分析
  7. 经验整理-win10安装ubuntu18.04.2双系统(NVIDIA Geforce GTX 1060独显)
  8. 处理Spring WebFlux中出现的错误
  9. EBGP使用环回口建邻居用到ebgp-multihop和update source loopback
  10. ENDNOTE中使用Adobe打开PDF后提示“只读无法保存”