How does iOS get a unique identifier for a device? What are the meanings of IDFA, IDFV and Udid respectively?

Source: Internet
Author: User
Tags vars

How does iOS get a unique identifier for a device? What are the meanings of IDFA, IDFV and Udid respectively? [Abstract: 1, UDID (unique device Identifier) UDID is a unique device Identifier, words too literally, it is the only Apple iOS device identification code, it is composed of 40 characters of letter war numbers. A lot needs to be limited]

First, UDID (Unique Device Identifier)
The full name of Udid is unique device Identifier, which, as its name implies, is the unique identifier of the Apple iOS device, which consists of 40 characters of letters and numbers. It is often used in many applications where it is necessary to restrict an account to a single device. The udid of the device can be obtained in iOS5, which was later banned by Apple.
Second, UUID (universally Unique Identifier)
UUID is universally unique identifier abbreviation, Chinese meaning is universal unique identification code. It is to allow all the elements in the distributed system to have unique identification information, and do not need to through the central control side to do the identification information designation. In this way, everyone can create a UUID that does not clash with others. In this case, there is no need to consider the name duplication problem when the database is established. Apple recommends using a UUID to generate a unique identification string for your app.
Developers can call once when the app is first launched, and then store the string instead of Udid. However, if the user deletes the app and then installs again, a new string is generated, so it is not guaranteed to uniquely identify the device. With UUID, consider the processing of the application being removed and then reinstalled. One solution: The UUID is usually generated only once, stored in the iOS system, if the app is deleted, after reloading the app its UUID is the same, unless the system resets. However, there is no guarantee that the system will be available after the upgrade (if the system saves the information).
Third, MAC Address

The identifier used to represent each site on the internet, in hexadecimal notation, with a total of six bytes (48 bits). Of these, the first three bytes are the code (high 24 bits) assigned by the registration Authority RA of the IEEE to different manufacturers, also known as the "unique identifier" (organizationally unique Identifier), and the last three bytes (low 24-bit) Adapter interfaces that are assigned to production by each manufacturer are called extension identifiers (uniqueness).

MAC address is used on the network to differentiate the uniqueness of the device, access to network devices have a MAC address, they must be different, is unique. There may be multiple MAC addresses on an iphone, including WiFi, SIM, and so on, but itouch and ipad have a WiFi connection, so just get the WiFi MAC address, which is En0 's address. The MAC address is just like the ID number on our ID card, which is globally unique. This can be very good to identify the device uniqueness, similar to the udid number of Apple devices, the usual use is: 1 for some statistical and analytical purposes, using the user's operating habits and data to better plan products; 2) as a user ID to uniquely identify the user, You can use the app as a visitor and save the appropriate information on the server side, eliminating the registration process such as user name, password, etc. The unique identification of the device using the MAC address is three main points: 1, using the "Address of Mac" 2 directly, using "MD5 (MAC Address)"
3. Use "MD5 (Mac address+bundle_id)" To obtain a unique identifier for "Machine + App" (bundle_id is the unique identity of the app) after iOS7, if the request MAC address will return a fixed value.
Iv. IDFA (Identifierforidentifier)

AD identifiers for external use: such as advertising, exchange, and other cross-application user tracking.

is another new method in iOS 6, provides a method advertisingidentifier, by calling the method will return a Nsuuid instance, finally can get a uuid, stored by the system. However, even though this is stored by the system, there are several cases where the ad identifier is regenerated. This ad identifier is regenerated if the user completely resets the system (restore location and privacy, general-purpose, Setup, and so on). In addition, if the user explicitly restores the ads (set-up, general-purpose, and so on, to the ads, and restore the ad identifiers), then the ad identifiers will be regenerated. With respect to the restoration of the ad identifier, it is important to note that if the program is running in the background, the user "restores the ad identifier" and then goes back to the program, and then gets the ad identifier and does not immediately get the restored identifier. You must terminate the program before restarting the program to obtain the restored AD identifier.

All apps on the same device will get the same value, and Apple is designed to track users with ads that are commercially available, and users can reset the value of this ID in Settings | privacy | Ad tracking, or limit the use of this ID, so the ID may not be able to get a value, but fortunately Apple is allowed to track by default, And the general user does not know that there is such a setting, so basically used to monitor the promotion effect, is more than the stamp.

Note: Since IDFA will not be available, it should never be used as the main ID for business analysis to identify users.

Code:

#import <AdSupport/AdSupport.h>  NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

Wu, IDFV (Identifierforvendor)

Vindor identifier for internal use: For example, analyzing user behavior within an app.

is for vendor to identify the user, each device in the same vender application, have the same value. The vender refers to the application provider, but to be exact, it is matched by the first two parts of the Bundleid DNS reversal, if the same is the same vender, for example, for Com.somecompany.appone, Com.somecompany.apptwo These two bundleid, they belong to the same vender, sharing the value of the same IDFV. Unlike IDFA, the value of IDFV can be taken, so it is well suited to identify the user as the primary ID for internal user behavior analysis, instead of Openudid.

Note: If the user uninstalls all apps that belong to this vender, the IDFV value will be reset, that is, the APP,IDFV value of this vender will be re-installed before the values are different.

Code:

  NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

Vi. OPEN UDID
The openudid for each iOS device is generated by the first app with the Openudid SDK package, and if you completely remove all apps with the Openudid SDK package (such as a recovery system, etc.), Openudid will regenerate and will be different from the previous values. equivalent to new equipment;
The advantage is that the MAC address is not used, the different devices can obtain their own unique identification code, ensure the uniqueness, can be used for the related purposes of the previous udid, from the Code analysis Openudid, the identification code is easy to obtain and save carefully. The disadvantage is that when you remove all applications that use the OPENUDID scheme on the device, and the device shuts down, Xcode clears and restarts, and reinstall the application to get Openudid, openudid changes, unlike before, all Openudid apps Uninstall , the data saved by Uipasteboard is erased and re-installed to retrieve the new Openudid. 

When the Uipasteboard data is purged due to user intervention or malicious programs, the Openudid is removed and the reload acquires a new openudid.

Openudid code that generates a unique identification code:

  1. unsigned char result[16];
  2. Const Char char*cstr = [[[Nsprocessinfo ProcessInfo] globallyuniquestring] utf8string];
  3. CC_MD5 (cStr, strlen (CSTR), result);
  4. _openudid = [NSString stringwithformat:
  5. @ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%08x",
  6. result[0], result[1], result[2], result[3],
  7. result[4], result[5], result[6], result[7],
  8. result[8], result[9], result[10], result[11],
  9. result[12], result[13], result[14], result[15],
  10. Arc4random ()% 4294967295];

How does iOS get a unique identifier for a device? What are the meanings of IDFA, IDFV and Udid respectively?

Related Article

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.