0

In my iOS app, I am using [NSDate date] to get the users' current datetime. This is an important element of the app but it seems that the users can change this value by manually change the time on their devices to something else. This small 'hack' ruins the idea of the app, and I am looking for a way to avoid this.

Any suggestions?

Simon Degn
  • 901
  • 1
  • 12
  • 40
  • 1
    How is the user setting the time on their device a *hack*? – Droppy Jun 02 '15 at 15:01
  • 1
    Even if the user doesn't manually change the device's date/time, it could still be wrong. Don't rely on it. – rmaddy Jun 02 '15 at 15:05
  • 2
    if you have a chance to collect the _date and time_ from an external server, you can use that link in your app: http://json-time.appspot.com/time.json – holex Jun 02 '15 at 15:05
  • See http://stackoverflow.com/questions/12221528/nsdate-get-precise-time-independent-of-device-clock?rq=1 – rmaddy Jun 02 '15 at 15:05

2 Answers2

1

If you can't rely on the time on your device you'll have to get it from a web service. Of course, if the network is slow or unavailable you won't be able to rely on it!

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152
1

I think that you should be using an Internet time server. They are using a standardized protocol called NTP. I would recommend you to use open-source project like IOS-NTP to get time for internet.