且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式获取IOS设备的UDID?

更新时间:2023-12-04 16:17:49

NSString* Identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; // IOS 6+
  NSLog(@"output is : %@", Identifier);

Swift 2.X(此处X以上版本均为2.0以上版本)

let Identifier: String = UIDevice.currentDevice().identifierForVendor().UUIDString()
NSLog("output is : %@", Identifier)

Swift3

let Identifier = UIDevice.current.identifierForVendor?.uuidString

    NSLog("output is : %@", Identifier! as String)

其他参考


Apple显然已开始删除对UDID的访问权限iOS5中的(唯一设备标识符)。无论如何,您现在可以用于识别目的的***方法是使用UUID(通用唯一标识符)。这必须基于每个应用程序。也就是说,无法再识别设备,但您可以在设备上识别应用程序。只要用户没有完全删除应用程序,那么此标识符将在应用程序启动之间保持不变,至少让您使用设备上的特定应用识别同一用户。不幸的是,如果用户完全删除然后重新安装应用程序,那么ID将会改变,但这是任何人都可以做的***的。

Apple is apparently starting to remove access to the UDID (Unique Device IDentifier) in iOS5. In any event, the best you can now do for identification purposes is to use a UUID (Universally Unique IDentifier). This has to be on a per-app basis. That is, there is no way to identify the device any longer, but you can identify an app on a device.As long as the user doesn’t completely delete the app, then this identifier will persist between app launches, and at least let you identify the same user using a particular app on a device. Unfortunately, if the user completely deletes and then reinstalls the app then the ID will change, but this is the best anyone can do going forward.