ios-ntp框架同步问题 [英] ios-ntp framework sync issue

查看:117
本文介绍了ios-ntp框架同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用从ipad应用程序github下载的ntp-ios框架来获取GTM时间,使用以下代码

  [NetworkClock sharedNetworkClock]; // //收集ntp服务器... 

[NSDate networkDate]; //这将给出网络的日期和时间,无论设备日期如何,如果设备的时间不正确,那么无论设备日期是



<那么我也正在获得正确的gmt时间。



但是我的问题是,当应用程序进入后台时,我在设置中更改了设备的时间。那么如果我再次通过点击它使应用程序激活,那么它给错误的gmt时间。如果我退出应用程序并重新启动它,那么在这种情况下它将按预期工作。请建议如何解决这个问题。



提前感谢。 。 。

解决方案

也许我不正确地理解问题,但在我看来,您可以使用ntp服务器获得GMT时间尝试获取在设备设置中设置的本地时间设置。



这些是两个不同的东西,如果您需要在应用程序到来时获取正确的时间到前台我将在AppDelegates applicationDidEnterForeground中调用您之前发布的相同方法...



如果您的应用程序不是严格依赖于正确的时间,我建议您使用当地时间的设备,我想你可以放心地假设大多数用户在他们的设备上设置正确的时间...


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 . . .

解决方案

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 ...

这篇关于ios-ntp框架同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆