有没有办法确定iOS中的实际时间和日期(不是设备的时间) [英] Is there a way to determine the actual time and date in iOS (not the time of the device)

查看:20
本文介绍了有没有办法确定iOS中的实际时间和日期(不是设备的时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 中,我需要知道实际时间 (UTC),而不是设备的时间.换句话说,用户应该不可能篡改时间或日期.

In iOS, I need to know the actual time (UTC), not the time of the device. In other words, it should not be possible for the user to tamper with the time or date.

任何需要网络连接的东西都不好(所以访问时间服务器不是一种选择).

Anything that requires a network connection is not good (so accessing a time server is not an option).

AFAIK,有两种理论上的方法可以实现这一点:

AFAIK, there are 2 theoretical ways of achieving this:

  • 使用 GPS 卫星信号中的时间戳
  • 从运营商处获取当前时间

问题是 iOS 中的任何 API 都不会公开此信息.

Problem is that this information is not exposed by any API in iOS.

还有其他方法吗?

推荐答案

您可能找到的大多数解决方案(包括从 CoreLocation 获取 GPS 数据以访问时间信息)都是有缺陷的,因为它们依赖于实际设备来访问时间.您将需要连接到时间服务器(我建议检查 NTP 服务器).我正在查看核心电话框架,但找不到任何可以提供网络时间的东西.您可能想要填写错误报告并请求苹果扩展其中一个类以包含时间.

Most solutions you could possibly find (including getting GPS data from CoreLocation to access the time information) are flawed because they are depending on the actual device to access time time. You will need to connect to a time server (i would suggest to check for NTP server). I was looking at the core telephony framework and couldn't find anything that would provide the network time. You might want to fill a bug report and request apple to expand one of the classes to include the time.

这篇关于有没有办法确定iOS中的实际时间和日期(不是设备的时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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