How can I get the “internet time” on iOS? [duplica

2019-05-04 13:10发布

问题:

This question already has an answer here:

  • Is there any way to get the tamper-proof date and time on iPhone? 1 answer

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?

回答1:

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