Deferring Location Updates not working

Do any of you guys experience the same issue that i’ve been experiencing. Here is my code:

let locationManager : CLLocationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.allowsBackgroundLocationUpdates = true
locationManager.activityType = CLActivityType.fitness
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.pausesLocationUpdatesAutomatically = false;

            locationManager.requestAlwaysAuthorization();
            locationManager.startUpdatingLocation()

and in my didUpdateLocations delegate i have this code:

if (CLLocationManager.deferredLocationUpdatesAvailable()) {
let timeInterval: TimeInterval = TimeInterval(60
locationManager.allowDeferredLocationUpdates(untilTraveled: CLLocationDistanceMax, timeout: timeInterval)
}

And this CLLocationManager.deferredLocationUpdatesAvailable() always returns false. I have an iPhone 6plus running iOS 11.0.3.

Hi @anand4u, what error are you getting from the debug console?

Hello @gdelarosa. Sorry for this late reply. This is the error that i am getting:

“The operation couldn’t be completed. (kCLErrorDomain error 11.)”

Hi @anand4u, thanks for providing the error, but I am unable to tell you why your issue is occurring based off that error message. Could you post a screenshot of the message on your debug console? I would also try to clean the project, deleting then re-downloading the app on the simulator, and restarting xcode. Sometimes those can be quick and easy fixes.

This topic was automatically closed after 166 days. New replies are no longer allowed.