【发布时间】:2019-11-15 09:52:07
【问题描述】:
当用户进入该区域时,我正在制作一个带有位置更新的 ibeacon 区域监控应用程序(应用程序不在前台)。此位置更新必须配置为 kCLLocationAccuracyBestForNavigation 精度(因为我必须在使用保持在该区域时进行跟踪, 订阅我的重大变化是不够的)。一切正常,但 20 秒后(有时 1 分钟以上)我停止接收位置更新。我将所有键都放在 info.plist 中以始终使用位置,我在功能部分中包含后台模式,并在后台更新位置。
我使用不同的配置配置 locationManager,并且 SO 总是停止我的位置更新。我正在使用 IOS 12 和 Iphone 7 进行测试。
我配置CLLocationManager的方式:
self.locationManager.desiredAccuracy
=kCLLocationAccuracyBestForNavigation
self.locationManager.activityType = .automotiveNavigation
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.delegate = self
self.locationManager.allowsBackgroundLocationUpdates = true
self.locationManager.pausesLocationUpdatesAutomatically = false
开始位置更新(当用户进入 Ibeacon 区域时):
func beaconManager(_ manager: KTKBeaconManager, didEnter region:
KTKBeaconRegion) {
self.locationManager.startUpdatingLocation()
}
最后,在 didUpdate 位置我调用了一个网络服务:
func locationManager(_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation]) {
//Call web service using alamofire
}
我寻求您的帮助,以了解我是否为我想要执行的目的正确执行了设置,以及任何可以让我知道操作系统为什么会终止我获取位置更新的进程的线索
【问题讨论】:
标签: ios swift core-location beacon region-monitoring