I need to make an api call based on the current user's location when the view starts.
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 50
locationManager.startUpdatingLocation()
}
The issue is that the delegate locationManager(didUpdateLocations)
gets called 3 times. Based on the answer How to stop multiple times method calling of didUpdateLocations() in ios it seems like it does that to get an increasingly accurate fix on the user's location.
I only want to call the api call once per significant Location change. (We don't need to do another search for nearby waypoints until the user has moved 50 meters).
The other stackoverflow answers shows how to only respond to the first location update and ignore the others in a short time interval. However it seems like I should use the most accurate of the initial location updates (the 3rd one in this case).
How can I implement such that it uses the most accurate of the initial burst of location updates. Does it always update 3 times reliably? Is there some other delegate method for when it has finished calibrating more accurate location updates?