Reputation: 1295
I encountered some problems using the core location in IOS. I can't figure out how the whole thing work...please help.
Scenario: iPhone with location services turned on. Wireless and 3G not on. iPhone in a building where GPS can't reach.
I have created my own program and i am using the core location functions by following the LocateMe example. I know that after calling startUpdatingLocation, didUpdateToLocation will be called with the last received GPS coordinates even if its outdated. I have 2 questions:
1) In didUpdateToLocation, when i print out newLocation.timestamp, it will show the iphone system time. I verify this by changing the date time in iphone settings. When the function is activated, the newLocation.timestamp will store the iphone system date time. Why is newLocation storing the system time when it cannot retrieve the GPS location? Anyway to determine the validity of the time stamp and check if its from GPS or system?
2) As the timestamp i received is the system time, how do i determine if the coordinates is an updated timestamp? Is the LocateMe example sufficient to deal with this issue?
Thanks!
Upvotes: 0
Views: 2306
Reputation: 54121
Core Location inserts the current system time when it received a new location update from whatever source. The iPhone does not use the GPS time sent by the satellites.
Usually, you calculate the time difference between "now" and the CLLocation timestamp to find out how fresh the update is. IME, Cached results are sent for all three location detection techniques (as long as available).
There's no direct indication of the source of the location update. However, there are some hints: Altitude, Vertical accuracy and speed are only set for GPS updates. WiFi-updates usually are in the 60 m horizontalAccuracy range whereas as cell tower updates are >500m.
Upvotes: 2