1

I'm trying to use DeferredLocationUpdates on my brand new iPhone 7 and iOS 10.1.1 and it always fails.

The code:

    locationManager.delegate = self
    locationManager.requestAlwaysAuthorization()
    locationManager.allowsBackgroundLocationUpdates = true
    locationManager.pausesLocationUpdatesAutomatically = true
    locationManager.activityType = .fitness
    locationManager.desiredAccuracy = kCLLocationAccuracyBest
    locationManager.distanceFilter = kCLDistanceFilterNone
    locationManager.headingFilter = kCLHeadingFilterNone
    locationManager.startUpdatingLocation()

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

    if !defersLocationUpdates {
        defersLocationUpdates = true
        locationManager.allowDeferredLocationUpdates(untilTraveled: CLLocationDistanceMax, timeout: CLTimeIntervalMax)
    }

}

But CLLocationManager.deferredLocationUpdatesAvailable() always returns false.

ha100
  • 1,563
  • 1
  • 21
  • 28
Arsen
  • 10,815
  • 2
  • 34
  • 46
  • This is a known issue. It has been discussed on Stack Overflow and bug reports have been filed. It is far from clear what good you think spending your rep on a bounty is going to do. You are merely duplicating (for example) http://stackoverflow.com/questions/39933965/allowdeferredlocationsupdates-working-on-the-simulator-but-not-on-my-iphone-6s A bug is a bug. Until the bug is fixed, deferred location updates are not working in iOS 10. That's just the way it is. – matt Nov 18 '16 at 01:57
  • Also here http://stackoverflow.com/questions/39498899/deferredlocationupdatesavailable-returns-no-in-ios-10 – kamwysoc Nov 18 '16 at 19:33
  • had you use above code in AppDelegate? – Hitesh Surani Nov 21 '16 at 06:23
  • Where is defersLocationUpdates? deffination and have define locationManager(_:didFinishDeferredUpdatesWithError:) delegate method – Hitesh Surani Nov 21 '16 at 06:35
  • Deprecated starting with iOS 13: https://developer.apple.com/documentation/corelocation/cllocationmanager/1620547-allowdeferredlocationupdates – William Grand Oct 20 '21 at 21:57

0 Answers0