首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLLocationManager startMonitoringForRegion:设备重启后不重新启动应用程序

CLLocationManager startMonitoringForRegion:设备重启后不重新启动应用程序
EN

Stack Overflow用户
提问于 2013-12-06 20:26:57
回答 1查看 2.3K关注 0票数 2

好的,我现在有一个应用程序,在这个应用程序中,我使用CLLocationManager startMonitoringForRegion方法注册了一个要监视的地理信息。当应用程序位于前台和后台时,这很好。

我还设置了适当的plist值:

代码语言:javascript
复制
UIBackgroundModes :{location}
UIRequiredDeviceCapabilities: {location-services}

什么不起作用

设备重新启动后,应用程序将不会重新启动。如果在输入背景之前设置startMonitoringSignificantLocationChanges,我可以强制这样做。但是这种方法使用的电池寿命要长得多,而且我并不总是需要定位,只是在我破坏地理位置的时候。

各地区的医生说:

In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so that it can process the event. When relaunched, all of the regions you configured previously are made available in the monitoredRegions property of any location manager objects you create.

问题

在不使用startMonitoringSignificantLocationChanges的情况下,(在使用地理区域时)系统在系统重新启动后重新启动我的应用程序是否可能?

编辑:我的目标是iOS6 & iOS7

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-11 00:46:58

在这里回答我自己的问题。

虽然您确实需要使用startMonitoringSignificantLocationChanges使系统在设备重新启动后唤醒应用程序。如果用户强行关闭了应用程序,什么也不会唤醒它。

出于我的目的,我不需要将UIBackgroundModes设置为location。此设置通常用于只需要细粒度位置更新(例如使用startUpdatingLocation)的应用程序。使用startMonitoringSignificantLocationChanges时不需要设置后台模式。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20432971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档