How does iOS obtain the unique identifier of a device? What are the meanings of IDFA, IDFV, and UDID ?, Idfaidfv
How does iOS obtain the unique identifier of a device? What are the meanings of IDFA, IDFV, and UDID? [Abstract: 1. UDID (Unique Device Identifier) UDID is called Unique Device Identifier, which is a Unique identification code of Apple IOS equipment, it consists of 40 characters of letters and war numbers. Many restrictions are required]
1. UDID (Unique Device Identifier)
The full name of UDID is Unique Device Identifier. as its name implies, it is the Unique Identifier of Apple IOS devices. It consists of 40 characters of letters and numbers. It is often used in many applications that require one device and one account. In iOS5, you can obtain the device's UDID, which is then disabled by Apple.
Ii. UUID (Universally Unique Identifier)
UUID is the abbreviation of Universally Unique Identifier. It enables all elements in a distributed system to have unique identification information without specifying the information through the central control terminal. In this way, each user can create a UUID that does not conflict with others. In this case, duplicate names are not required during database creation. Apple recommends that you use UUID to generate a unique identifier string for the application.
The developer can call the string once when the application is started for the first time, and store the string to replace the UDID. However, if the user deletes the application and installs it again, a new string is generated, so the device cannot be uniquely identified. When using UUID, you must consider the processing when the application is deleted and then re-installed. A solution is: UUID is generally generated only once and stored in the iOS system. If the app is deleted, its UUID is the same after the app is reinstalled, unless it is reset by the system. However, it cannot be ensured that the system can be used after the system is upgraded (if the system saves the information ).
3. MAC Address
The identifier of each site on the Internet. It is expressed in hexadecimal notation and contains six bytes (48 bits ). Among them, the first three bytes are the code (up to 24 bits) allocated to different manufacturers by the IEEE Registrar RA ), it is also known as "Organization uniquely identified Identifier". The last three bytes (24 bits at low bits) are automatically assigned to the adapter interface of production by each manufacturer, it is called an extension identifier (uniqueness ).
MAC addresses are used to differentiate the uniqueness of devices on the network. All devices connected to the network have a MAC address. They must be different and unique. An iPhone may have multiple MAC addresses, including WIFI and SIM, but there is a WIFI address on iTouch and iPad, so you only need to get the MAC address of WIFI, that is, the address of en0. The MAC address is like the ID number on our ID card and is globally unique. In this way, the device uniqueness can be well identified, similar to the UDID Number of Apple devices. The common uses include: 1) for some statistical and analysis purposes, use users' operation habits and data to better plan products. 2) use the app as the user ID to uniquely identify users and store corresponding information on the server, the user name and password registration process is skipped. The unique identifier of a device generated using a Mac Address is divided into three types: 1. Use "MAC Address" directly 2. Use "MD5 (MAC Address )"
3. Use "MD5 (Mac Address + bundle_id)" to obtain the unique ID of "machine + application" (bundle_id is the unique ID of the Application) after iOS7, if the Mac address is requested, a fixed value is returned.
Iv. IDFA (identifierForIdentifier)
Ad identifiers are suitable for external users, such as Ad Promotion and traffic change.
This is another new method in iOS 6. It provides the advertisingIdentifier method. By calling this method, an NSUUID instance is returned, and a UUID is obtained, which is stored by the system. However, even if this is stored by the system, the ad identifier is re-generated in several cases. If the user completely resets the system (set the program-> General-> restore location and privacy), the AD identifier will be generated again. In addition, if the user explicitly restores the advertisement (set the program-> General-> about the local machine-> advertisement-> restores the advertisement identifier), the advertisement identifier will be generated again. For how to restore the ad identifier, note that if the program runs in the background, the user "restores the ad identifier" and then returns to the program, in this case, obtaining the advertising identifier does not immediately obtain the restored identifier. You must terminate the program and restart the program to obtain the restored ad identifier.
All apps on the same device get the same value, which Apple designed for advertising providers to track users, users can reset the value of this id in Settings | privacy | ad tracking, or restrict the use of this id, so the id may not be taken, however, Apple allows tracing by default, and users generally do not know this setting. Therefore, it is sufficient to have a timestamp to monitor the promotion effect.
Note: Because idfa cannot be obtained, it cannot be used as the primary id of business analysis to identify users.
Code:
#import <AdSupport/AdSupport.h> NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
5. IDFV (identifierForVendor)
Vindor identifier, applicable to internal: for example, analyzing users' behaviors in applications.
It is used to identify the user of the Vender. Each device has the same value in the application of the same Vender. The Vender refers to the application provider, but to be accurate, it is matched by the first two parts of the DNS reversal of BundleID. If they are the same, it is the same Vender. For example, for com. somecompany. appone, com. somecompany. apptwo bundleids belong to the same Vender and share the same idfv value. Different from idfa, The idfv value can be obtained. Therefore, it is very suitable for identifying users and replacing OpenUDID as the primary id for internal user behavior analysis.
Note: If a user uninstalls all apps belonging to this Vender, The idfv value is reset, that is, the App of this Vender is reinstalled. The idfv value is different from the previous one.
Code:
NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
6. OPEN UDID
The OpenUDID of each iOS device is generated by the first App with the OpenUDID SDK package. If you delete all the apps with the OpenUDID SDK package (such as restoring the system ), openUDID will be generated again, and it will be different from the previous value, which is equivalent to the new device;
The advantage is that MAC addresses are not used. Different devices can obtain their unique identifiers to ensure uniqueness and can be used for previous udids. From code analysis, openudids are obtained, the identifier is easy to obtain and saved with caution. The disadvantage is that when you delete all applications on the device that use the OpenUDID scheme, and the device is shut down and restarted, xcode is completely cleared and restarted, and the application is reinstalled to obtain the OpenUDID. At this time, the OpenUDID changes, different from before, after all OpenUDID applications are uninstalled, the data saved by UIPasteboard is cleared. Therefore, the new OpenUDID will be retrieved after the application is reinstalled.
When UIPasteboard data is cleared due to user intervention or malicious programs, the OpenUDID is deleted and the new OpenUDID is obtained after reinstallation.
Code for generating a unique identifier using OpenUDID:
- Unsigned char result [16];
- Const charchar * cStr = [[NSProcessInfo processInfo] globallyUniqueString] UTF8String];
- CC_MD5 (cStr, strlen (cStr), result );
- _ OpenUDID = [NSString stringWithFormat:
- @ "% 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 02x % 08x ",
- Result [0], result [1], result [2], result [3],
- Result [4], result [5], result [6], result [7],
- Result [8], result [9], result [10], result [11],
- Result [12], result [13], result [14], result [15],
- Arc4random () % 4294967295];