CLLocationManager.requestLocation()
takes around 10 seconds to fire didUpdateLocations
event.
Here are the attributes set for the CLLocationManager
let locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 10
locationManager.requestWhenInUseAuthorization()
locationManager.requestLocation()
As per the documentation this can take several seconds.
This method returns immediately. Calling it causes the location manager to obtain a location fix (which may take several seconds) and call the delegate’s locationManager(_:didUpdateLocations:) method with the result.
But can this take 10 long seconds? Or am I missing something?
If you switch out the
locationManager.requestLocation()
for
locationManager.startUpdatingLocation()
then didUpdateLocations
will start firing immediately. This should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With