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

好的,所以我现在有一个应用程序,我使用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

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

虽然您确实需要使用startMonitoringSignificantLocationChanges来让系统在设备重启后唤醒应用程序。 如果用户强行closures它,没有任何东西会唤醒应用程序。

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