CLLocationManager didFailWithError: what error stops location updates

1k Views Asked by At

The iOS CLLocationManager reports various errors in its didFailWithError method: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CoreLocationConstantsRef/Reference/reference.html#//apple_ref/c/econst/kCLErrorDenied

In the documentation it is not clear which of these error (except kCLErrorDenied and kCLErrorLocationUnknown) stop the location manager and location updates?

Regards,

2

There are 2 best solutions below

1
Balram Tiwari On

Try to print your error object description. You will get to know what was the reason for failure. The possible reason could be either you haven't granted permission to use location to your app or manually have revoked to use location.

If you are failing in simulator then make sure the simulator is pointing to some custom location.

0
J Kasparian On

In my experience, these errors do not stop the location manager. You may however need to handle possible changes in the authorizations by using the function

func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
    // here you call the function where you manage the location authorizations at the launch of the app
}