Getting time from GPS on iOS

I am working on a tracer application. The application requires to know the location of the device with high accuracy, i.e. Uses location services and ignores locations with horizontal accuracy worse than 20 meters. CLLocation not explicitly declared if it is detected via GPS or not. However, if the horizontal accuracy is 20 meters or better, it can be assumed that this location is from GPS.

In addition, I need to know the timestamp when the location was determined. I know about the timestamp property in the CLLocation class. However, I would like to get the timestamp from the GPS, not the system time.

Can I get GPS time? I don’t care about cases when the GPS signal is not available. I just need to get the GPS time for the GPS location (high accuracy location) that I just got.

For other stackoverflow questions, the following code snippet is suggested:

 CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0]; NSDate* now = location.timestamp; 

Is there any guarantee that location.timestamp is something more GPS related than [NSDate date] ?

This does not seem to be the case if the automatic time setting is turned off. If I go to Settings → General → Date and time and turn off “Set automatically”, the timestamp property contains the manually set system time. Is it more - GPS is connected, at least when the automatic time setting is enabled?

+4
source share
2 answers

I think the timestamp is calculated on the side of the device and most likely is not related to the satellite timestamp.
CoreLocation is completely opaque, and it seems unlikely from Apple that you can access raw data, such as the timestamps of GPS satellites ...

0
source
 However, I would like to get the timestamp from GPS, not the system time. 

You cannot get the timestamp provided by the GPS chip.

If the user artificially sets the wrong time, ios also uses this offset in their places.

 I just need to get the GPS time for a GPS location (location with high accuracy) I have just received. 

If your device is set to automatically adjust the system time, the GPS time should be clear.

 So is it more-GPS related at least when automatic time setting is turned on? 

Yes

 Is there any guarantee that location.timestamp is something more GPS-related than [NSDate date]? 

Its always more related, [NSDate date] is the current system time, and location.time is the time associated with the time the location was recorded. This can be compensated, for example, 0.6 or even more for the first correction after launch.

To check if the current location is or not, Apple recommends calculating the difference between the system time and the location time.

+2
source

All Articles