5

So, I'm developing an app that is based on the time, but with NSDate an user can easily hack the application by changing system time of the device. So I might want to use a better method for retrieving time.

How can I do this? Is there an easy way to retrieve time from internet?

Davide Di Febbo
  • 301
  • 5
  • 14

1 Answers1

6

Checkout this Google Library: https://github.com/jbenet/ios-ntp

After the library is set up you can use it with the following line:

[NSDate networkDate];

A similar question has also been answered here: Get Date and Time from Apple Server

Community
  • 1
  • 1
Ben-G
  • 4,996
  • 27
  • 33
  • 1
    I found out "ios-ntp" is not reliable in case of app is moving from foreground to background or vice versa, In these scenario it is giving me device time. Please help if my assumptions are wrong. – Nasir Jul 11 '17 at 09:02