I. UDID (Unique Device Identifier)
UDID is an abbreviation for unique device identifier, in Chinese meaning it is a unique identifier.
It is often used in many applications where an account is limited to one device, and in the Symbian era, we use the IMEI as the unique identifier of the device, but Apple officially does not allow the developer to acquire the IMEI of the device.
How to get in the iOS5 SDK:
- [Uidevice Currentdevice] uniqueidentifier]
The definition of uniqueidentifier in UIDevice.h is as follows:
- @property (nonatomic,readonly,retain) nsstring *uniqueidentifier __osx_available_but_deprecated (__MAC_NA,__MAC_NA, __IPHONE_2_0,__IPHONE_5_0); //A string unique to each device based on various hardware info.
This means that iOS2.0 and iOS5.0 systems are available, but are not recommended for use. It is possible for Apple to remove the function after ios5.0.
Tested, jailbroken iphone with a system version of 5.0.1, you can still get udid.
But one thing we need to be aware of is that Udid is not unique to a jailbroken device. With the Cydia plug-in Udidfaker, you can assign different Udid to each app.
So the use of Udid as the identity of the unique device has been small.
Two. UUID (universally Unique Identifier)
UUID is universally unique identifier abbreviation, Chinese meaning is universal unique identification code.
The UUID is a software-built standard and is also organized by the Open Source Software Foundation (Open software FOUNDATION,OSF) in a distributed computing environment (distributed Computing ENVIRONMENT,DCE), as shown by online data Part of the field. The purpose of the UUID is to allow all elements in a distributed system to have unique identification information without the need to specify the information through the central control terminal.
According to the above definition, the UUID of different applications on the same device is mutually exclusive, which means that the application can be identified on the device. However, it is not clear that you can identify different devices that have the same application, but according to my assumptions, this UUID should generate a unique identifier based on the device identity and application identity, and then encrypted ( Pure speculation).
The code for getting the UUID in iOS is as follows:
- 1-(nsstring*) uuid {2 Cfuuidref puuid = cfuuidcreate (nil); 3 Cfstringref uuidstring = cfuuidcreatestring (Nil, Puu ID); 4 NSString * result = (NSString *) cfstringcreatecopy (NULL, uuidstring); 5 cfrelease (PUUID); 6 cfrelease (uuidstring); 7 return [result autorelease]; 8}
Although the UUID is an official proposed alternative to the UDID proposal, but there is information on the Internet that the UUID can not be guaranteed after the upgrade of the system (ios6,7) can also be used.
I tested it. Currently, the UUID can be used under IOS4 and IOS5, and the UUID generates different values each time, requiring the developer to save the UUID itself.
If you use UUID to save the user's data on the network, when the user reload the software, the value of the UUID may change (basically, it will change), the user will not be able to re-download the original network data.
Three. A workable solution
Through the above discussion, it is not difficult to find, whether using Udid or UUID, our purpose is usually to allow users to automatically register, without the need for account password. Using Udid and UUID as the user's ID is not without blemish.
Now there is a ready-made solution on the Web, using the MAC address of the device, because the MAC address is also unique. UNIX has a system call to get the MAC address. But there are some things to note:
1.iPhone may have multiple MAC addresses, the address of the WiFi, and the address of the SIM card. Generally speaking, we take En0 's address, because he is the address of the iphone WiFi, is definitely present. (The exception remains: a portion of the market still has a part of the castrated version of the iphone without WiFi)
2.MAC address involves privacy, should not randomly spread the user's MAC address! So we need to hash the MAC address before it can be uploaded as DeviceID.
With regard to the first point of attention, after my test, no wifi function of the same iphone3gs can get MAC address, so this should be the only one of the best identification device solution.
Solution Githubgithub. Com/gekitz/uidevice-with-uniqueidentifier-for-ios-5
background:
Most applications use the UDID number of the Apple device, and Udid usually has the following two uses:
1) for some statistical and analytical purposes; "third-party statistical tools such as friends, advertisers such as AdMob, etc."
2) Udid as the user ID to uniquely identify the user, save the user name, password and other registration process.
However, in 2011, Apple announced that ios5.0 's system would no longer support the following methods to obtain the user's Udid "unique ID number for Apple devices":
- [Uidevice Currentdevice] uniqueidentifier];
Note: For jailbroken devices, Udid is not unique. Using the Cydia plugin udidfaker, you can assign different Udid to each app "
At the same time, Apple recommends using the UUID "an open Software building standard" to replace:
- -(nsstring*) uuid {
- Cfuuidref Puuid = cfuuidcreate (nil);
- Cfstringref uuidstring = cfuuidcreatestring (nil, puuid);
- NSString * result = (NSString *) cfstringcreatecopy (NULL, uuidstring);
- Cfrelease (PUUID);
- Cfrelease (uuidstring); return [result autorelease];
- }
Each time the method gets a unique identifier string, the developer can call it once at the first launch of the app, and then store the string for later substitution with Udid.
The problem is that if the user deletes the app and then installs it again, a new string is generated, so it is not guaranteed to uniquely identify the device.
Recently (March 2012), it was reported that the Apple App Store was refusing to use the Udid app shelves.
Alternative scenarios:
Now there is a ready-made solution on the Web, using the MAC address of the device, because the MAC address is also unique. UNIX has a system call to get the MAC address. But there are some things to note:
1.iPhone may have multiple MAC addresses, the address of the WiFi, and the address of the SIM card. Generally speaking, we take En0 's address, because he is the address of the iphone WiFi, is definitely present.
2.MAC address involves privacy, should not randomly spread the user's MAC address! So we need to hash the MAC address before it can be uploaded as DeviceID.
The solution Source Address: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
The program provides two methods:
Uniquedeviceidentifier (returns the MD5 value for Mac and Cfbundleidentifier)
Uniqueglobaldeviceidentifier (return Mac's MD5 value)
How to use:
- #import "Uidevice+identifieraddition.h" NSLog (@ "%@", [[Uidevice Currentdevice] uniquedeviceidentifier]);
- NSLog (@"%@", [[Uidevice Currentdevice] uniqueglobaldeviceidentifier]);
Test results:
Under WiFi:
Udid:xxxx21f1f19edff198e2a2356bf4xxxx
Newly generated: xxxx7dc3c577446a2bcbd77935bdxxxx
3G under:
Udid:xxxx21f1f19edff198e2a2356bf4xxxx
Newly generated: xxxx7dc3c577446a2bcbd77935bdxxxx
GPRS under
Udid:xxxx21f1f19edff198e2a2356bf4xxxx
Newly generated: xxxx7dc3c577446a2bcbd77935bdxxxx
Flight mode:
Udid:xxxx21f1f19edff198e2a2356bf4xxxx
Newly generated: xxxx7dc3c577446a2bcbd77935bdxxxx
After removing the app reload:
Udid:xxxx21f1f19edff198e2a2356bf4xxxx
Newly generated: xxxx7dc3c577446a2bcbd77935bdxxxx
IOS----------Some understanding of Udid and UUID