Get serial number of device on iOS 8

前端 未结 4 1712
孤独总比滥情好
孤独总比滥情好 2021-02-14 23:44

For an in-house application, we were using the following code UIDevice+serialNumber to get the device serial number. However, it seems that with iOS 8, the registry key \"IOPlat

相关标签:
4条回答
  • 2021-02-15 00:31

    The serial number for Apple devices can be found under Settings -> General -> About -> Serial number.

    0 讨论(0)
  • 2021-02-15 00:34

    Answer: No.

    There are currently floating solutions around abusing the .mobileconfig, but they add other problems due their nature.

    UUID was removed for a reason. See the news around privacy and the summon of Apple by the US Senat from 2011 to gain an understanding why this had to be changed. http://arstechnica.com/apple/2011/04/apple-google-asked-to-join-judiciary-hearing-on-mobile-device-privacy/

    Abusing the underlying march port to get the device serial number as replacement of the UUID is not the solution. Same now for abusing the mobile config and guess how long that will work.

    You have plenty of decent ways to handle any situation where you used device identification before. Especial in an enterprise environment where you have cryptography and MDM is absolutely no point to track a device like this.

    0 讨论(0)
  • 2021-02-15 00:40

    As Helger stated above, UDID is no longer available in iOS 6+ due to security / privacy reasons. Instead, use identifierForVendor or advertisingIdentifier Please check UDID Replacement APIs

    For iOS 8+

    + (NSString *)deviceUUID
    {
    if([[NSUserDefaults standardUserDefaults] objectForKey:[[NSBundle mainBundle] bundleIdentifier]])
        return [[NSUserDefaults standardUserDefaults] objectForKey:[[NSBundle mainBundle] bundleIdentifier]];
    
    @autoreleasepool {
    
        CFUUIDRef uuidReference = CFUUIDCreate(nil);
        CFStringRef stringReference = CFUUIDCreateString(nil, uuidReference);
        NSString *uuidString = (__bridge NSString *)(stringReference);
        [[NSUserDefaults standardUserDefaults] setObject:uuidString forKey:[[NSBundle mainBundle] bundleIdentifier]];
        [[NSUserDefaults standardUserDefaults] synchronize];
        CFRelease(uuidReference);
        CFRelease(stringReference);
        return uuidString;
     }
    }
    

    You can use identifierForVendor after that store them to keychain and use later. Because value of keychain will not changed when re-install app.

    I used to use Open UDID for this purpose. Don't know if it still works.

    0 讨论(0)
  • 2021-02-15 00:43

    Retrieving the device serial number directly is no longer possible in iOS.

    However, if it's simply for an internal enterprise app, something the company I work for is going to implement is this:

    During device configuration, copy the serial number and set the device name as the serial number.

    Then use Apple's UIDevice API to retrieve the device name.

    0 讨论(0)
提交回复
热议问题