【问题标题】:Can i get iPhone purchase/first time use date [closed]我可以得到 iPhone 购买/首次使用日期 [关闭]
【发布时间】:2018-01-12 07:22:44
【问题描述】:

我的要求是获取 iOS 设备的购买日期。能不能通过代码实现。

【问题讨论】:

  • 答案 - 无法检测到。所以别再和它打架了。
  • 不,不可能。该信息即使在设备上可用,也不会被 API 公开。

标签: ios


【解决方案1】:

简短的回答:不。您可以获得的最佳信息是有关设备何时打开的信息

#include <sys/sysctl.h>

struct timeval boottime;

int mib[2] = {CTL_KERN, KERN_BOOTTIME};
size_t size = sizeof(boottime);
time_t now;
time_t uptime = -1;

(void)time(&now);

if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) {
    uptime = now - boottime.tv_sec;
}

NSDate *bootDate = [NSDate dateWithTimeIntervalSinceNow:((NSTimeInterval)-uptime)]

【讨论】:

  • 请记住,这在很大程度上依赖于私有 API,因此如果您的应用中有此功能,Apple 拒绝您的应用进入 App Store。
  • Not necessarily。此外,如果这个api不应该被使用,它就不会被暴露出来。
  • 私有 API 是私有的是有原因的。如果您使用私有 API 并被抓住,您的应用将被拒绝,因为它违反了 AppStore 的规则。开发人员发现了一些私有 API,但能够使用某些东西并不等于被允许使用它......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多