2

好的,所以我目前有一个应用程序,我在其中注册要使用该CLLocationManager startMonitoringForRegion方法监控的地理围栏。当应用程序位于前台和后台时,这可以正常工作。

我还设置了适当的 plist 值:

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

4

1 回答 1

6

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

虽然您确实需要使用startMonitoringSignificantLocationChanges让系统在设备重启后唤醒应用程序。如果用户强制关闭应用程序,则不会唤醒应用程序。

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

于 2013-12-11T00:46:58.970 回答