According to Apple's own documentation around CLLocationManager
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
locations.last // this is supposed to be the most recent
}
However, during development, I sometimes notice that locations.last
is sometimes minutes to hours out of date.
abs(locations.last.timestamp.timeIntervalSinceNow) // sometimes very large (e.g. 500, 5000, etc)
Does anyone have any ideas what might be causing this issue?
When Location Service can't get the current location by requesting GPS server.
It will return the cached/recent location. That is why you see its timestamp is 1 min or 1 hour ago.
It will return the cached/recent location.
This will help users to quickly access their current locations if they didn't travel significantly, that is when Accelerometer works to measure the movement of the device.