Is there a way to determine the actual time and date in iOS (not the time of the device)(有没有办法确定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中的实际时间和日期(不是设备的时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法确定iOS中的实际时间和日期(不是设备的时间)
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
