ios-ntp framework sync issue

僤鯓⒐⒋嵵緔 提交于 2020-01-15 08:42:52

问题


I am using ntp-ios framework downloaded from github in my ipad application to get the GTM time , by using the following code

    [NetworkClock sharedNetworkClock]; // // gather up the ntp servers ...

    [NSDate networkDate]; // This will give the network date and time regardless of device date

if the device time is wrong , then also i am getting the correct gmt time .

but my problem is , when application goes to background and i changed the device time in settings . then after that if i again make application active by tapping on it , then it's giving wrong gmt time . if i quit the application and launch it again , in that case it's working as expected . please suggest how to fix this .

Thanks in advance . . .


回答1:


Maybe I am not understanding the question correctly but it seems to me that you get the GMT time with the ntp servers and then attempting to get the devices local time settings, that are set in the devices Settings.

These are two different things, if you need to get the correct time when the application comes to foreground I would call those same methods you posted before in the AppDelegates applicationDidEnterForeground ...

If your application is not critically dependent on the correct time I would suggest that you use the local time of the device, I think you could safely assume that most users have the correct time set on their devices ...



来源:https://stackoverflow.com/questions/18845981/ios-ntp-framework-sync-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!