如何访问iOS 8.1(及以上版本)中的硬件序列号?

如何访问iOS 8.1(及以上版本)中的硬件序列号?,ios,iphone,ios8.1,Ios,Iphone,Ios8.1,从iOS 8.1开始,它似乎不再能够使用IOKit访问序列号: CFTypeRef serialNumberAsCFString; io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); serialNumberAsCFString = IORegistryEntryCreateCFProperty(

从iOS 8.1开始,它似乎不再能够使用IOKit访问序列号:

CFTypeRef serialNumberAsCFString;
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));

serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);

IOObjectRelease(platformExpert);

NSString *sn = CFBridgingRelease(serialNumberAsCFString);
此时serialNumberAsCFString将为0x0,因此sn为空

那么现在如何检索序列号呢?或者这已经不可能了


我完全知道IOKit是一个私有框架,它的使用将导致应用被拒绝。

崩溃?什么错误?试试CfBrigingRelease。@nicael谢谢!CfBrigingRelease修复了崩溃,但字符串仍然为空。因此,只使用NSString*sn=CfBrigingReleaseSerialNumberAsCfString,而不是stringWithFormat…啊,找到了。这是IORegistryEntryCreateCFProperty,自iOS 8以来不再工作。我们必须找到另一种方法。