How to get Device UDID in programmatically in iOS7?

前端 未结 10 2212
梦谈多话
梦谈多话 2020-12-04 18:33

How to get device UDID in programatically in iOS7.[[UIDevice currentDevice] uniqueIdentifier] I was used this code This is deprecated iOS7. how to get the devic

相关标签:
10条回答
  • 2020-12-04 18:59

    Use identifierForVendor or advertisingIdentifier.

    identifierForVendor:

    An alphanumeric string that uniquely identifies a device to the app’s vendor. (read-only)
    
    The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
    

    advertisingIdentifier:

    An alphanumeric string unique to each device, used only for serving advertisements. (read-only)
    
    Unlike the identifierForVendor property of UIDevice, the same value is returned to all vendors. This identifier may change—for example, if the user erases the device—so you should not cache it.
    

    Also, see Apple's documentation for the identifierForVendor and advertisingIdentifier.

    0 讨论(0)
  • 2020-12-04 19:04

    In iOS 7, Apple now always returns a fixed value when querying the MAC to specifically thwart the MAC as base for an ID scheme. So you now really should use -[UIDevice identifierForVendor] or create a per-install UUID.

    Check this SO Question.

    0 讨论(0)
  • 2020-12-04 19:04

    For getting UDID: (If you're using this Might be App store guys won't allow it --> As per my concern)

    - (NSString *)udid
    {
    void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY);
    CFStringRef (*MGCopyAnswer)(CFStringRef) = (CFStringRef (*)(CFStringRef))(dlsym(gestalt, "MGCopyAnswer"));
    return CFBridgingRelease(MGCopyAnswer(CFSTR("UniqueDeviceID")));
    }
    
     **Entitlements:**
     <key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>
       <array>
    <string>UniqueDeviceID</string>
    </array>
    

    For Getting UUID:

        self.uuidTxtFldRef.text = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    
    0 讨论(0)
  • 2020-12-04 19:06

    In Swift 3.0:

    UIDevice.current.identifierForVendor!.uuidString
    

    old version

    UIDevice.currentDevice().identifierForVendor
    

    you want a string:

    UIDevice.currentDevice().identifierForVendor!.UUIDString
    
    0 讨论(0)
提交回复
热议问题