Ios LocationManager未使用筛选器更新
我有一个LocationManager,我们用来记录企业的iPad位置,出于某种原因,它会随机触发它,即使我已经正确设置了(我相信)它。位置背景已打开。我正在使用Parse和Parse Server最终保存,但不是它没有记录,就是它没有保存。我甚至还制作了无声音频,让应用程序在后台保持完全活跃,而且它在某种程度上做到了这一点。这是我正在使用的代码,我是否遗漏了什么Ios LocationManager未使用筛选器更新,ios,swift,cllocationmanager,Ios,Swift,Cllocationmanager,我有一个LocationManager,我们用来记录企业的iPad位置,出于某种原因,它会随机触发它,即使我已经正确设置了(我相信)它。位置背景已打开。我正在使用Parse和Parse Server最终保存,但不是它没有记录,就是它没有保存。我甚至还制作了无声音频,让应用程序在后台保持完全活跃,而且它在某种程度上做到了这一点。这是我正在使用的代码,我是否遗漏了什么 locationManager.delegate = self switch CLLocationManager.a
locationManager.delegate = self
switch CLLocationManager.authorizationStatus() {
case .NotDetermined:
locationManager.requestAlwaysAuthorization()
case .AuthorizedAlways:
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.distanceFilter = 100
self.locationManager.startUpdatingLocation()
default:
break
}
及
我不知道你有什么问题。。如果您的问题是location manager每次都会更新,那么您需要在func locationManager(manager:CLLocationManager,didUpdateLocations locations:[CLLocation])中使用:locationManager.StopUpdateLocation()。我的问题是它没有像应该的那样每100米更新一次。它是随机进行的,我不知道为什么不是每100米一次。只要在city ride的模拟器中运行代码,你就会看到它工作。对我来说,它每500米更新一次,而不是在设备中每100米更新一次。我不知道你的问题是什么。。如果您的问题是location manager每次都会更新,那么您需要在func locationManager(manager:CLLocationManager,didUpdateLocations locations:[CLLocation])中使用:locationManager.StopUpdateLocation()。我的问题是它没有像应该的那样每100米更新一次。它是随机进行的,我不知道为什么不是每100米一次。只要在city ride的模拟器中运行代码,你就会看到它在工作。对我来说,它每500米更新一次,而不是每100米更新一次
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.last {
let loc = LocationTracker()
loc.timeStamp = location.timestamp
loc.device = UIDevice.currentDevice().name
if PFUser.currentUser() != nil {
loc.user = PFUser.currentUser()
}
loc.location = PFGeoPoint(location: location)
loc.saveEventually()
}
}