微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iphone – 通过避免应用程序10分钟的时间限制,持续在后台工作

我想创建一种服务类应用程序,它在后台运行但问题是在iOS应用程序中有10分钟的限制.

我们有什么方法可以连续运行我们的应用程序,我已经阅读了一些内容,如果我们在后台播放一首歌,那么应用程序永远不会在10分钟后终止,但我不认为苹果会批准这一点.

任何建议都会有所帮助.

解决方法

来自iOS开发人员库:

iOS 7 supports two new background execution modes for apps:

Apps that regularly require new content can register with the system
and be woken up or launched periodically to download that content in
the background. To register,include the uibackgroundmodes key with
the fetch value in your app’s Info.plist file,and set the minimum
time you want between fetch operations using the
setMinimumBackgroundFetchInterval: method. You must also implement the
application:performFetchWithCompletionHandler: method in your app
delegate to perform any downloads. Apps that use push notifications to
notify the user that new content is available can Now use those
notifications to initiate background download operations. To support
this mode,include the uibackgroundmodes key with the
remote-notification value in your app’s Info.plist file. Your app
delegate must also implement the
application:didReceiveRemoteNotification:fetchCompletionHandler:
method.

第一种情况:
通过设置setMinimumBackgroundFetchInterval:以UIApplicationBackgroundFetchIntervalMinimum或在几秒钟内任何其他号码(您的AppDelegate内)会通知您的应用程序需要更新其内容,即使它是在后台系统.

请注意.获取间隔是最小值而不是最大值!因此,当系统决定时,您的应用会被唤醒.这可能是一天一次或一天多次.在我的情况下,我的应用程序正在更新约.每10分钟一直到19:00.在那之后,花了大约.下次更新需要7个小时,下次更新需要3个小时.第二天,相同(每10分钟至19:00).

如果您要求从互联网定期更新(高效和低电量消耗),这种技术是理想的,但不适用于需要在短时间内更新的内容,如电池电量或电池状态.

希望这可以帮助.

iOS 7仍处于测试版.因此,上述所有内容可能会更改或更新,直到正式发布

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐