Wake app at regular intervals while using UIBackgroundModes=location

ⅰ亾dé卋堺 提交于 2019-12-12 03:22:52

问题


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.


回答1:


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...



来源:https://stackoverflow.com/questions/9384306/wake-app-at-regular-intervals-while-using-uibackgroundmodes-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!