Identifier for iOS

 

The full name of UDID is Unique Device Identifier .

It can also be seen from the name that the UDID is related to the device, and it is only related to the device, which is somewhat similar to the MAC address. I mentioned real machine debugging in the blog " iOS from certificate generation to packaging and shelf - 02 ", and then I need to add the UDID to the Provisioning Profile authorization file, that is, add the unique identifier of the device to identify a certain equipment.   UDID is a 40 -digit hexadecimal sequence, we can use iTunes and Xcode to get this value.

It was available in previous versions, but is deprecated in iOS5 and later. Although this UDID is widely used, it has to be said that it is slowly moving away from developers and cannot be considered using UDID anymore. It remains to be seen whether this identifier will be turned into a private method, or removed entirely from future iOS versions. However, this UDID is very handy when deploying enterprise-level signature programs. The method to obtain the UDID is as follows:

NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];

Example : bb4d786633053a0b9c0da20d54ea7e38e8776da4

 

 

CFUUID
SinceiOS2.0,CFUUIDhas appeared. ItCoreFoundatiopackage, so theAPIisC-style. The CFUUIDCreate method is used to create aCFUUIDRef, and a correspondingNSString, as follows:

CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault);NSString *cfuuidString = (NSString*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, cfuuid));

 

The obtained CFUUID value is not stored by the system. Each time CFUUIDCreate is called , the system returns a new unique identifier. If you wish to store this identifier, you will need to store it yourself in NSUserDefaults , Keychain , Pasteboard or elsewhere.

 

 

The name Vindor identifier ( IDFV-identifierForVendor )
was also added iniOS 6, but a new way to get thisIDFVwas added to the existingUIDeviceclass. LikeadvertisingIdentifier, this method returns anNSUUIDobject.

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

 

Apple's official documentation has the following description for identifierForVendor :

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

 

If such conditions are met, the acquired attribute value will not change: in the same program - the same vindor - the same device. If this is the case, then the value will not be the same: same program - same device - different vindor , or same program - different device - same vindor or not .

 

After reading the above content, I have such a question " what is vendor ". My first thought was the Apple Developer Account. But it turned out to be wrong. Then I thought maybe there was an AppIdentifierPrefix thing, like keychain access, that could be shared across multiple programs. Again, the idea is true. It turns out that vendor is pretty simple: a Vendor is the first two parts of a CFBundleIdentifier (inverted DNS format). For example, com.doubleencore.app1 and com.doubleencore.app2 get the same identifierForVendor because the first two parts of their CFBundleIdentifier are the same. However, the identifierForVendor obtained in this way is completely different: com.massivelyoverrated or net.doubleencore .

 

Here, it should also be noted that if the user uninstalls all programs corresponding to the same vendor , and then reinstalls the programs provided by the same vendor , the identifierForVendor will be reset.

Example : 599F9C00-92DC-4B5C-9464-7971F01F8370

 

At this time, the printed string UUIDString is not the real UDID , but a substitute that looks a bit like. As I said above, UDID is only related to iOS devices, and this identifierForVendor is related to both the application and the device. When application A is installed on Zhang San's device, an identifierForVendor will be generated (for example: 1234 ) ; When application A is installed on Li Si's device, another identifierForVendor will be generated (for example: 5678 ); When application B is installed on Zhang San's device, it will be a brand new identifierForVendor (for example: 9999 ), B When the application is installed on Li Si's device, it is still a brand new identifierForVendor (for example: 7777 ). But no matter how many times the A application is installed and uninstalled, the result is 1234.   So we know that thisidentifierForVendor is an identifier generated by application plus device binding, which is equivalent to: Z ( identifierForVendor ) = X (an application) + Y (a device). Of course, the difference from the real UDID is obvious: that is to say , the developer of the App has no way to distinguish a certain device, but can only identify an application on a certain device.

 

Advertising Identifier ( IDFA-identifierForIdentifier )
This isanother new method iniOS 6. advertisingIdentifier is part of the new frameworkAdSupport.framework. The ASIdentifierManagersingleton provides a methodadvertisingIdentifierinstanceNSUUIDmentioned above by calling this method

NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

 

Unlike CFUUID and NSUUID , advertising identifiers are stored by the system. But even though this is stored by the system, there are several cases where the ad identifier is regenerated. If the user completely resets the system ((Settings- > General- > Reset- > Restore Location & Privacy), this ad identifier will be regenerated. Also if the user explicitly resets the ad (Settings- > General- > About This Mac) -> Advertisement- > Restore the ad identifier), then the ad identifier will also be regenerated. One thing to note about the restoration of the ad identifier: if the program is running in the background, the user "restores the ad identifier" at this time, and then Going back to the program, getting the advertisement identifier at this time will not immediately get the restored identifier. You must terminate the program and then restart the program to get the restored advertisement identifier. The reason for this is that I guess it is Since ASIdentifierManager is a singleton.


There is a controllable switch "Limit Ad Tracking" for ad identifier users. Already pointed out in Nick Arnott 's article . Turning this switch on doesn't actually do anything, but hopefully restricts your access to ad identifiers. This switch is a simple boolean flag, when sending the ad identifier to any server side, you'd better judge the value before making a decision.

Example : 1E2DFA89-496A-47FD-9941-DF1FC4E6484A

 

 

 

NSUUID
NSUUID
only appearediniOS 6is almost exactly the same asCFUUIDObjective-Cinterface. +(id)UUIDis a class method that can be called to get aUUID. A UUIDstringcan be obtained by the following code

NSString *uuid = [[NSUUID UUID] UUIDString];

 

Like CFUUID , this value is not stored by the system, and a new unique identifier is obtained each time it is called. If you want to store it, you need to store it yourself. When I read the NSUUID , I noticed that the value obtained is exactly the same as the CFUUID (although it may not be the same):

Example : 68753A44-4D6F-1226-9C60-0050E4C00067

 

Keychain



 

We can get the identifierForVendor , and then save the identifierForVendor in the KeyChain .

In this way, even if the APP is deleted and installed, it can be read back from the KeyChain . Using group can also ensure that all programs of the same developer can obtain the same constant identifierForVendor for the same device .

 

But the identifierForVendor will still change after flashing or reinstalling the system .

 

code:https://github.com/easyui/EZToolKit/blob/master/EZToolKit/EZCategory/Foundation/NSString/NSString%2BEZ_Helper.m

thx:

iOS Unique Identifier Guide

Get the unique UUID of an iOS device

Detailed explanation of iOS UDID and UUID

iOS uses keychain to treat identifierForVendor as a unique identifier. replace advertisingIdentifier

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326327557&siteId=291194637