Is there a way to determine the actual time and date in iOS (not the time of the device)

前端 未结 3 1321
春和景丽
春和景丽 2021-01-17 13:16

In iOS, I need to know the actual time (UTC), not the time of the device. In other words, it should not be possible for the user to tamper with the time or date.

Any

相关标签:
3条回答
  • 2021-01-17 13:37

    You could have a look at secondsFromGMTForDate: and secondsFromGMT in NSTimeZone. If the GMT offset increases/decreases when the time of the device is changed, these provide a way to correct your timestamps to GMT (and probably convert to UTC).

    0 讨论(0)
  • 2021-01-17 13:40

    You can't get to the raw GPS data and the timestamp property of the CLLocation in locationManager:didUpdateLocations: is set with the system clock

    0 讨论(0)
  • 2021-01-17 13:47

    Most solutions you could possibly find (including getting GPS data from CoreLocation to access the time information) are flawed because they are depending on the actual device to access time time. You will need to connect to a time server (i would suggest to check for NTP server). I was looking at the core telephony framework and couldn't find anything that would provide the network time. You might want to fill a bug report and request apple to expand one of the classes to include the time.

    0 讨论(0)
提交回复
热议问题