********闹钟的特殊实现形式,无法解决的难题******

rollrock1987 2015-10-29 10:18:32
闹钟的原理我知道,无非就是使用Local Notification来实现,但是最近看到一个闹钟应用,觉得很新奇,大概说下它的表现:
1.如果把它从后台结束,那用的是普通的Notification形式出现。(也就是弹出通知)。
2.如果让它在后台运行(也就是按了home键,具体有没有在后台执行还是有疑问的,后面会说到),到了时间,它就一直在播放音乐以及震动。

疑问:
1.对于第一条,没有问题,本地通知就是这样的。
2.对于第二条,请问是如何实现的呢?按我的理解,app肯定是在后台偷偷的运行的,原理是神马呢?我通过查资料,找到如下文章,http://oleb.net/blog/2014/02/alarm-clock-apps-ios/ 里面的一段话是
Rise’s surprising solution is to opt out of iOS multitasking altogether. What was presumably intended by Apple as a temporary option for apps when multitasking was first introduced in iOS 4.0 is still available:
{If you do not want your app to run in the background at all, you can explicitly opt out of background by adding the UIApplicationExitsOnSuspend key (with the value YES) to your app’s Info.plist file. When an app opts out, it cycles between the not-running, inactive, and active states and never enters the background or suspended states.}

You can observe this behavior in Rise when you leave the app and immediately reopen it: it relaunches from scratch, showing the launch image again, rather than just wake up from the background.

需要把UIApplicationExitsOnSuspend 设置为YES,然后这里提到的 “when you leave the app and immediately reopen it: it relaunches from scratch, showing the launch image again, rather than just wake up from the background.” 是什么意思,如何实现呢?
...全文
101 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧