Is there an alternative to ios-ntp to get atomic/ current time ios?

后端 未结 1 1578
渐次进展
渐次进展 2021-01-03 08:37

In my app I want to get the accurate date and time , Basically, in my application there is going to be a time sensitive portion that users can not start until after a certai

1条回答
  •  被撕碎了的回忆
    2021-01-03 09:07

    Do you realise you are asking the impossible? If you need to get the time and you don't have network connectivity, the only place to get the time from is the device. Either you trust the device time, or you get the time from NTP. There are no other choices.

    How you handle this depends on exactly why you need to get the time. If, there is functionality in your app that absolutely must not be enabled before a certain date, I would get the time from an external server and if it proves to be after the said date, set a flag in your defaults to say you have verified the date and the functionality is allowed, so you don't need to network connectivity thereafter. If the networking connectivity is not there, you don't set the flag but maybe put a message up to say that you need to connect to the Internet to enable the new functionality.

    If it's just some part of a game, use device time and let them cheat if they want.

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