使用UIBackgroundModes = location定期唤醒应用程序 [英] Wake app at regular intervals while using UIBackgroundModes=location

查看:109
本文介绍了使用UIBackgroundModes = location定期唤醒应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个导航应用程序,该应用程序使用UIBackgroundModes=location设置并通过didUpdateToLocation接收CLLocationManager更新.很好

I'm developing a navigation app which uses the UIBackgroundModes=location setting and receives CLLocationManager updates via didUpdateToLocation. That works fine.

问题在于位置更新之间的间隔很难预测,我需要确保应用程序每隔几秒钟被调用一次,以完成其他(微小)数量的工作,即使位置没有变化显着地.

The problem is that the intervals between location updates are very hard to predict and I need to make sure the app is called something like once every few seconds to do some other (tiny) amounts of work even if the location did not change significantly.

我可以这样做吗?我可以这样做吗?我该怎么办?

Can I do that? Am I allowed to do that? And how can I do that?

我发现了博客文章,但我不确定这是否真的可以继续.

I found a blog post, but I'm not sure if this is really the way to proceed.

推荐答案

允许的后台操作范围很有限.例如,您不能仅在应用程序处于后台状态时让NSTimer运行以执行一些任意代码-因此,对您问题的简单回答是,不能.一定要阅读Apple文档中有关允许和不允许的内容(允许的大部分内容与需要"特定的持续服务(例如播放音乐或响应位置更改的功能的应用程序有关)(GPS类型的应用程序...).您可以通过响应位置或重要的位置更改通知来构建可行的解决方案...

Permissible background operations are pretty limited in scope. You cannot, for example, just leave an NSTimer running to perform some arbitrary code while your application is in the background - so the simple answer to your question is no, you cannot. Definitely read the Apple documentation regarding what is and isn't allowed (most of what's allowed pertains to apps that "need" specific ongoing services, like the ability to play music, or respond to location changes (GPS type apps...). You may be able to construct a viable solution by responding to location or significant location change notifications...

这篇关于使用UIBackgroundModes = location定期唤醒应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆