LocationManager不使用过滤器更新

时间:2016-10-24 14:34:29

标签: ios swift cllocationmanager

我有一个LocationManager,我们用它来记录一个企业的iPad位置,由于某种原因它会随机触发它,即使我已正确设置它(我相信)。位置背景已开启。我正在使用Parse和Parse Server来保存,但要么不记录它,要么不保存。我甚至努力制作无声音频,让应用程序在后台完全保持活力,并在某种程度上做到这一点。这是我正在使用的代码,我错过了什么?

    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
    }

    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()
    }
}

0 个答案:

没有答案