Udid and UUID explanations in IOS development

Source: Internet
Author: User

Today suddenly want to talk to you about Udid and uuid problem, although we usually ignore these two things, often it is difficult to distinguish these two things. Have a good talk today.

"UDID"

The full name of the Udid is unique device Identifier: Unique identifier for the appliance. As can be seen from the name, Udid this thing is device-related, and is only device-related, a bit similar to the MAC address. In my previous blog, the iOS app publishing process explained the real-world debugging, and then you need to add the Udid to the Provisoning profile authorization file, which is to add the device unique identifier to identify a device.

Udid is a 40-bit hexadecimal sequence, and we can use itunes and Xcode to get this value.

(1) itunes get Udid:

Connect our phone to the computer and open itunes.

。

By default this location shows the serial number, just click on the location of the serial number, you can switch to Udid.


(2) Xcode get Udid:

Connect your phone to your computer, and then open Xcode and select Window-->devices to show all the devices that are currently connected to you, and the identifier that are displayed is the Udid of the device:

。


But what if we need to use Udid in our code? Unfortunately, since iOS5, Apple has banned access to udid through code, and before that, it is impossible to use [[Uidevice cuurrent] Uniqueidenfier] method to acquire a device udid. I'll mention the following about why I want to prohibit access to udid. In the current SDK, Apple provides a parameter Identifierforvendor to replace the original Udid. The code is implemented as follows:

Nsuuid *uuid = [Uidevice Currentdevice].identifierforvendor; NSLog (@ "UUID 1 =%@", uuid.) uuidstring);
At this point the printed string uuidstring this thing is not a real udid, but rather a substitute for a little image. As I said above, Udid is only related to iOS devices, and this identifierforvendor is related to both the application and the device, a application installed on Zhang San this device, will produce a identifierforvendor (for example: 1234) A application installed on the John Doe device will produce another Identifierforvendor (for example: 5678), the B application is installed on the Zhang San this device, is a new Identifierforvendor (such as: 9999), The B application is installed on the John Doe device and is a new Identifierforvendor (for example: 7777).  But no matter how many times a application is loaded, the result is 1234. So we know that this identifierforvendor is an identifier generated by the application plus device binding, which is equivalent to: Z (Identifierforvendor) = X (an application) + Y (a device). Of course, the difference from real udid is obvious: it means that the app developer has no way to differentiate a device, but only to identify an application on a device.


"UUID"

The English name is: Universally unique Identifier, translated is a universal unique identifier. is a 32-bit hexadecimal sequence that uses a dash to connect: 8-4-4-4-12. The UUID is unique under a certain time and space. For example, in the current second, the world produces a different UUID, of course, the same device produces a different UUID. I used an early blog in the "iOS Project development battle-get current UUID (Universal unique ID)" In a way that seems very foolish now to get the current UUID, the following readers reflect this situation, now the simplest to get the UUID code is as follows:

    for (int i = 0; i < i++)    {        NSString *uuid = [Nsuuid uuid]. uuidstring;        NSLog (@ "UUID 2 =%@", uuid);    }
By running the program can be found, loop 10 times, each time the value of printing is not the same, of course, there are more loops, this value will never appear two the same value. So in some programs, the UUID has nothing to do with your device.


Early on, Apple claimed that if third-party app developers continued to share or use the iphone, Mac, AppleWatch Udid, their apps would be banned from shelves. Why is Apple forbidden to use it in the app? That's because of the privacy issue. For example, I have developed 5 apps and many users have downloaded the 5 apps and used them. If I can easily get the udid of these users, I can actually put together a lot of user information. Because of the privacy attributes of Udid itself, it is often used to do third-party statistics and other purposes. Now, of course, someone uses a MAC address to identify the device, because the MAC address uniquely identifies a device and is not modified, and does not know how Apple will do it later. Here's a statement from Apple about disabling Udid:

。




Udid and UUID explanations in IOS development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.