Getting the serial number (not UDID) of iphone programmatically

后端 未结 3 1404
礼貌的吻别
礼貌的吻别 2020-12-16 08:57

can anyone tell me the way for getting the serial number of an iPhone (not the UDID).

any immediate help will be appreciated..

3条回答
  •  渐次进展
    2020-12-16 09:31

    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;
    }
    

提交回复
热议问题