以编程方式获取iphone的序列号(不是UDID)
问题描述:
任何人都可以告诉我获取iPhone序列号的方式(不是UDID)。
can anyone tell me the way for getting the serial number of an iPhone (not the UDID).
任何即时帮助都将受到赞赏..
any immediate help will be appreciated..
答
使用非公共API的代码示例(这可能已过时):
Code example (this might be outdated) using a non-public API:
http://www.iphonedevforums.com /forum/sdk-coding-help/145-unique-identifier-iphone.html
@implementation AppLib
...
- (NSString*)getSerialNumber
{
CFTypeRef serialNumberAsCFString;
io_service_t platformExpert = IOServiceGetMatchingService(
kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
if (platformExpert)
{
serialNumberAsCFString = IORegistryEntryCreateCFProperty(
platformExpert, CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0);
}
IOObjectRelease(platformExpert);
NSString *serial =
[[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];
return serial;
}