ios UDID 和 UUID 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21872233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Differences between UDID and UUID
提问by user960567
Some people say UDID(Unique Device IDentifier)
and some say UUID(Universally Unique IDentifier)
. Are they are the same or not? What are the differences between them?
有人说UDID(Unique Device IDentifier)
,有人说UUID(Universally Unique IDentifier)
。它们是一样的还是不一样的?它们之间有什么区别?
回答by Rugmangathan
UUID (Universally Unique IDentifier)Is on a per-app basis. identifies 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.
UUID(通用唯一标识符)基于每个应用程序。标识设备上的应用程序。只要用户没有完全删除应用程序,这个标识符就会在应用程序启动之间保持不变,并且至少可以让您在设备上使用特定应用程序识别同一用户。不幸的是,如果用户完全删除然后重新安装应用程序,则 ID 将更改。
UDID (Unique Device Identifier)A sequence of 40 hexadecimal characters that uniquely identify an ios device. This value can be retrieved through iTunes, or found using UIDevice -uniqueIdentifier. Derived from hardware details like MAC address.
UDID (Unique Device Identifier)一个 40 个十六进制字符的序列,唯一标识一个 ios 设备。该值可以通过 iTunes 检索,或使用 UIDevice -uniqueIdentifier 找到。源自硬件详细信息,如 MAC 地址。
回答by user3182143
You better to go through this- http://nshipster.com/uuid-udid-unique-identifier/
你最好通过这个 - http://nshipster.com/uuid-udid-unique-identifier/
UUID(Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by RFC 4122.
UDID(Unique Device Identifier): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will). This value can be retrieved through iTunes, or found using UIDevice -uniqueIdentifier. Derived from hardware details like MAC address.
UUID(通用唯一标识符):一个 128 位的序列,可以保证跨空间和时间的唯一性,由RFC 4122定义。
UDID(唯一设备标识符):40 个十六进制字符的序列,唯一标识 iOS 设备(设备的社会安全号码,如果您愿意)。该值可以通过 iTunes 检索,或使用 UIDevice -uniqueIdentifier 找到。源自硬件详细信息,如 MAC 地址。
回答by morroko
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.
苹果显然开始在 iOS5 中移除对 UDID(唯一设备标识符)的访问。无论如何,您现在可以为识别目的做的最好的事情是使用 UUID(通用唯一标识符)。这必须基于每个应用程序。也就是说,无法再识别设备,但您可以识别设备上的应用程序。只要用户没有完全删除应用程序,这个标识符就会在应用程序启动之间保持不变,并且至少可以让您在设备上使用特定应用程序识别同一用户。不幸的是,如果用户完全删除然后重新安装应用程序,那么 ID 将会改变,但这是任何人都可以做的最好的事情。
回答by codercat
Since from iOS 5, Apple has deprecated the UIDevice uniqueIdentifier , that means traditional way of getting the unique id of each iOS device won't work now ie.
[[UIDevice currentDevice] uniqueIdentifier]
fails from iOS 5 and more.
从 iOS 5 开始,Apple 已弃用 UIDevice uniqueIdentifier ,这意味着获取每个 iOS 设备的唯一 id 的传统方式现在将不起作用,即。
[[UIDevice currentDevice] uniqueIdentifier]
从 iOS 5 及更多版本失败。
So for the alternative to the UUID , we can use the CFUUID class of Apple in order to create unique id for device. But, we really need to keep in mind that this inbuild class will create random numbers so they will return different ids on every call. Don't use NSUserDefaults for storing it, best way is to use Keychain.
因此,对于 UUID 的替代方案,我们可以使用 Apple 的 CFUUID 类来为设备创建唯一的 id。但是,我们真的需要记住,这个 inbuild 类将创建随机数,因此它们将在每次调用时返回不同的 id。不要使用 NSUserDefaults 来存储它,最好的方法是使用 Keychain。
So, here I am giving you the best way of using it in order to use it as a unique key for your device.
因此,在这里我为您提供使用它的最佳方式,以便将其用作您设备的唯一密钥。
- (NSString *)createNewUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}
UDID:
你做了:
回答by simalone
UDID, which is Unique Device Identifier, applied in iTunes, manage devices in your apple development certificate. it can be got by following code, in iOS5 SDK:
UDID,即Unique Device Identifier,应用在iTunes中,管理你的苹果开发证书中的设备。它可以通过以下代码获得,在iOS5 SDK中:
[UIDevice currentDevice] uniqueIdentifier];
define is:
定义是:
@property(nonatomic,readonly,retain) NSString *uniqueIdentifier __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA,__MAC_NA,__IPHONE_2_0,__IPHONE_5_0); // a string unique to each device based on various hardware info.
UUID, which is Universally Unique Identifier, an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE)(wiki).
UUID,即通用唯一标识符,一种用于软件构建的标识符标准,由开放软件基金会 (OSF) 标准化,作为分布式计算环境 (DCE) ( wiki) 的一部分。
You can get UUID by following code:
您可以通过以下代码获取 UUID:
-(NSString*) uuid {
CFUUIDRef puuid = CFUUIDCreate( nil );
CFStringRef uuidString = CFUUIDCreateString( nil, puuid );
NSString * result = (NSString *)CFStringCreateCopy( NULL, uuidString);
CFRelease(puuid);
CFRelease(uuidString);
return [result autorelease];
}
But, in iOS7 device, above method will return the same value for difference device.
但是,在 iOS7 设备中,上述方法将为不同的设备返回相同的值。
There are many methods to fetch unique identifiers in the link
有很多方法可以获取链接中的唯一标识符