How do you programmatically get the serial number of an iPhone?

后端 未结 3 831
Happy的楠姐
Happy的楠姐 2021-02-01 10:07

I want to know the serial number of my iPhone using my application. I have writen code below.

- (NSString*)getSerialNumber
{
 CFTypeRef serialNumberAsCFString;
         


        
相关标签:
3条回答
  • 2021-02-01 10:40

    Ready to use category on UIDevice: UIDevice+serialNumber. Not sure this would be accepted on the App Store.

    0 讨论(0)
  • 2021-02-01 10:44

    You should change the argument 2 of IORegistryEntryCreateCFProperty from CFSTR (kIOPlatformUUIDKey) to CFSTR (kIOPlatformSerialNumberKey). Then you will get the correct serial number(with length of 11 characters).

    0 讨论(0)
  • 2021-02-01 10:46

    Are you linking the IOKit framework?

    Try the

    id getValue(NSString *iosearch);
    

    function, available at

    http://blogs.oreilly.com/iphone/2008/08/retrieving-device-information.html

    You can also use the UIDevice class to retrieve other useful information For instance, you can do:

    NSString *id = [[UIDevice currentDevice] uniqueIdentifier];
    

    Other useful properties are the following ones:

      name  
      systemName    
      systemVersion  
      model  
      localizedModel  
    
    0 讨论(0)
提交回复
热议问题