I recently found a library called TrueTime for getting the time which does not depend on device time. It uses NTP to get the time.
https://github.com/instacart/TrueTime.swift
As this library is primarily built for swift 3. But I found a post in which there were some changes made in files to make it swift 4 compatible.
https://github.com/instacart/TrueTime.swift/issues/39
As I am using swift & using pod for this library. I unlocked the pods & made changes in the library to make work with swift 4.
How reliable is this library?
My concerns are
Apple approval after submitting an app.
Support for coming swift & iOS versions.
Are there better alternatives to this library?
Apple definitely won't reject that. It's not in the Review Guidelines. I even have an app that uses TrueTime on the app store.
Regarding reliability, if you mean reliability by "how reliable it is to get correct true time", then it's quite reliable. It seems like that the library gets the time from time.apple.com
. That seems to be from Apple, so I would say you can rely on it.
If you mean reliability by "how reliable it is to make successful requests" then that depends a lot: the user's Internet connection, bugs in the TrueTime library etc. According to the README,
Reachability events are automatically accounted for to pause/start requests.
UDP requests are executed in parallel, with a default limit of 5 parallel calls. If one fails, we'll retry up to 3 times by default.
So that's how the requests will behave.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With