ios - CLLocationManager startMonitoringForRegion : not relaunching app after device restart

标签 ios core-location cllocationmanager geofencing

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

我还设置了适当的 plist 值:

UIBackgroundModes :{location}
UIRequiredDeviceCapabilities: {location-services}

什么不起作用

设备重启后,应用不会重新启动。如果我在进入后台之前设置 startMonitoringSignificantLocationChanges ,我可以强制发生这种情况。但是这种方法会消耗更多的电池生命周期,而且我不需要一直需要位置信息,只是在我打破地理围栏时才需要。

区域文档说:

在 iOS 中,您向位置管理器注册的区域在您的应用程序启动之间保持不变。如果在您的 iOS 应用程序未运行时发生区域交叉,系统会自动在后台唤醒它(或重新启动它),以便它可以处理该事件。重新启动时,您之前配置的所有区域都可以在您创建的任何位置管理器对象的 monitoredRegions 属性中使用。

问题

是否有可能(在使用地理围栏区域时)让系统在系统重启后重启我的应用程序,而不使用 startMonitoringSignificantLocationChanges

编辑:我的目标是 iOS6 和 iOS7

最佳答案

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

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

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

关于ios - CLLocationManager startMonitoringForRegion : not relaunching app after device restart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20432971/

相关文章:

jquery - 焦点输入上的 Mobile Safari jQuery select() 不起作用

ios - Cococapods 框架导致警告 "Class XY is implemented in both"

ios - Appstore 拒绝 5. 1.5 合法 : Privacy - Location Services

ios - 从Singleton Object呈现iOS 8 UIAlertController

iphone - UIAlertView 像 "Turn On Location Services to allow maps to determine your location"。设置+取消

ios - 位置服务 : LocationAlways vs LocationWhenInUse

ios - 自定义 HeaderView 只显示在最后一个 Section

ios - 如何在 iOS 上高效地使用 REST API 的值对象

swift - CLLocationManager、核心数据和数组

ios - 如何在 map 中显示 iBeacon