IOS device get Unique identifier summary

Source: Internet
Author: User
Tags uuid reverse dns

On March 21, 2013 Apple has informed the developer that, from May 1, 2013 onwards, apps that access Uidid will no longer be audited, the alternative is that developers should use the vendor or advertising identifiers described in iOS 6.


Unique identifier is about to exit, Apple gave us vendor and advertising identifier two choices, but which one should be used? The document does not give a definitive answer, which is exactly what you decide to use for your app. Below I will list the currently supported and deprecated unique identifiers methods in iOS and explain them accordingly, hoping to help you make the right decision.

Cfuuid
From the beginning of the iOS2.0, Cfuuid had already appeared. It is part of the Corefoundatio package, so the API belongs to the C language style. The cfuuidcreate method is used to create the cfuuidref, and a corresponding nsstring can be obtained, as in the following code:

Cfuuidref Cfuuid = cfuuidcreate (Kcfallocatordefault); NSString *cfuuidstring = (nsstring*) cfbridgingrelease (cfuuidcreatestring (Kcfallocatordefault, Cfuuid));

The system is not stored for this cfuuid value. Each time you call Cfuuidcreate, the system returns a new unique identifier. If you want to store this identifier, you need to store it yourself in Nsuserdefaults, Keychain, pasteboard, or somewhere else.

Nsuuid
Nsuuid only appears in iOS 6, which is almost exactly the same as cfuuid, except that it is a objective-c interface. The + (ID) UUID is a class method that calls the method to obtain a UUID. A UUID string can be obtained by using the following code:

NSString *uuid = [[Nsuuid uuid] uuidstring];

Like Cfuuid, this value system is not stored 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 was exactly the same as cfuuid (though it might be different):

Example: 68753a44-4d6f-1226-9c60-0050e4c00067

Ad identifiers (Idfa-identifierforidentifier)
This is another new approach in iOS 6, andAdvertisingidentifier is part of the new framework adsupport.framework. The Asidentifiermanager Singleton provides a method for Advertisingidentifier, which returns a Nsuuid instance mentioned above by calling the method.

NSString *adid = [[[Asidentifiermanager Sharedmanager] advertisingidentifier] uuidstring];

Unlike Cfuuid and Nsuuid, ad identifiers are 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. I guess this is because Asidentifiermanager is a single case.


The user has a controllable switch to "limit ad tracking" for the ad identifier. Nick Arnott's article has been pointed out. Turn this switch on and actually do nothing, but that's what you want to limit your access to the ad identifier. This switch is a simple Boolean flag, and when you send the ad identifier to any server side, you'd better judge the value and then make the decision.

Example: 1e2dfa89-496a-47fd-9941-df1fc4e6484a

Vindor identifiers (Idfv-identifierforvendor)
This is also added to iOS 6, but the new method of getting this IDFV is added to the existing Uidevice class. As with Advertisingidentifier, this method returns a Nsuuid object.

NSString *IDFV = [[[Uidevice Currentdevice] Identifierforvendor] uuidstring];

Apple's Official document has the following description of Identifierforvendor:

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

If such a condition is met, then the obtained value of this property will not change: the same device inside the same program-the same vindor-. If this is the case, then this value will not be the same: the same program-the same device-different vindor, or the same program-different devices-whether or not the same vindor.

After reading the above, I have a question like "What is Vendor". The first thing I think about is the Apple developer account. But it turns out to be wrong. And then I thought maybe there was a appidentifierprefix thing, like keychain access, can be shared among multiple programs. The same is true of the idea. Finally, vendor is very simple: a vendor is the first two parts of the cfbundleidentifier (reverse 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. But the Identifierforvendor is completely different: com.massivelyoverrated or Net.doubleencore.

One thing to note here is that if the user uninstalls all the programs for the same vendor and then re-installs the program provided by the same vendor, Identifierforvendor will be reset at this point.

Example: 599f9c00-92dc-4b5c-9464-7971f01f8370


UDID
Available in previous versions, but in IOS5 and later versions, and deprecated. Although this udid is used extensively, it has to be said that it is slowly moving away from the developer and cannot consider using UDID. It remains to be seen whether the identifier is to be private or to be removed entirely from a later version of iOS. However, this udid is very handy when deploying an enterprise-class signature program. Here's how to get Udid:

NSString *udid = [[Uidevice currentdevice] uniqueidentifier];

Example: BB4D786633053A0B9C0DA20D54EA7E38E8776DA4

Openudid
When iOS 5 was released, uniqueidentifier was deprecated, causing the vast majority of developers to look for a solution that would replace Udid and not be controlled by Apple. This Openudid became the most widely used open source Udid alternative. Openudid is easy to implement in engineering and supports a range of advertising providers.

NSString *openudid = [Openudid value];

Openudid has used a very ingenious method of storing identifiers between different programs-a special name used to store identifiers in the pasteboard. In this way, other programs (also using Openudid) know where to go to get the identifiers that have been generated (instead of generating a new one).

As already mentioned, in the future, Apple will start forcing the use of advertisingidentifier or Identifierforvendor. If this day comes, even openudid looks like a great choice, but you may have to transition to Apple's approach.

Example: 0D943976B24C85900C764DD9F75CE054DC5986FF

Summarize
Hopefully the information above will help you choose the right unique identifier for your program use. Here, I created a small unique identifier test program , you can run the program and look at what is displayed (including all the identifiers mentioned above). In addition, there are two tables in the table that describe two things: usability in iOS, and when to get a reset identifier.


* The program must be restarted to see the effect of the change.
* * Remove All programs provided by the same vendor to see the changed values.

A way to compare compromises ***********

We can get a unique identifier based on the push of Devicetoken + boundid (MD5), stored on your own. If the user deletes the program. Then this identifier also dies. But we can keep a copy of the service. Created again is still the same.

IOS device get Unique identifier summary

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.