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
时不需要设置背景模式。
- CLLocationManager geo-fencing / startMonitoringForRegion:vs. startMonitoringForSignificantLocationChanges:与10分钟的startUpdating调用
- 在Mapview Xcode中更新位置
- 在App的多个部分调用位置
- didUpdateLocations永远不会调用swift
- 如果后台应用程序无法自动启动,Cardcase如何在某个位置启动?
- 区域监视当前位置不会退出时通知
- Swift 2 – 不能用CLLocationManager获取用户位置
- CLLocationManager委托方法没有被调用
- IOS 8 CLLocationManager问题(授权不工作)