Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLLocationManager.requestLocation() takes about 10 seconds

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?

like image 910
Yasas Karunarathna Avatar asked Sep 14 '16 20:09

Yasas Karunarathna


1 Answers

If you switch out the

locationManager.requestLocation()

for

locationManager.startUpdatingLocation() 

then didUpdateLocations will start firing immediately. This should solve your problem.

like image 107
bradchattergoon Avatar answered Oct 23 '22 03:10

bradchattergoon