Typically, iOS systems use Nsuserdefaults to store data, but for some private information, such as passwords, certificates, and so on, you need to use a more secure keychain.
The information stored in the keychain is not lost due to the app being deleted. Therefore, this keychain feature can be used to preserve the unique identity of the device.
So, how to use keychain in the application, we need to import security.framework, Keychain operation Interface declaration in the header file SecItem.h.
Directly using the SecItem.h method to operate the keychain, the code needs to write more complex, we can use the already encapsulated tool class Keychainitemwrapper to operate on keychain.
Keychainitemwrapper is the Apple official example "Generickeychain" in a keychain common operation of the package class, after downloading the Generickeychain project on the official website,
Just copy the "KeychainItemWrapper.h" and "KEYCHAINITEMWRAPPER.M" to our project and import the Security.framework. (xcode5 keychainitemwrapper.m to remove the automatic reference count )
nsmutablestring *str1 =[nsmutablestring string];// keychainitemwrapper *keychainitem = [[ Keychainitemwrapper alloc] initwithidentifier:@ "UUID" accessgroup:@ "com.itrun.www"];// [Keychainitem resetkeychainitem];// // NSString *uuidstr = [Keychainitem objectforkey: (__bridge ID) ksecvaluedata];// if (Uuidstr.length = = 0) { //Unique identifier generated place nsstring *myuuidstr = [[Uidevice currentdevice] Identifierforvendor] uuidstring];// [Keychainitem setobject:myuuidstr forkey: (__bridge ID) ksecvaluedata];// str1 = myUUIDStr;// }// else{// str1 = [Keychainitem objectforkey: (__bridge ID) ksecvaluedata];// }// MyLog (@ "======%@", str1); 050BBA53-7388-4CFF-991D-FEB548065CDF //5023a8e8-233f-4391-b119-2234996537e9
However, when the IOS8 debugging, the error occurs.
To identify a user, the first option is to select an identifier that identifies the user's device (not the user), which guarantees that the value returned on one device is the same, and that the same value does not appear on other devices.
Before IOS7, there had been many ways to identify the user's device, from the most original device Udid, MAC address, to an open source solution widely used by the ad statistics platform Openudid.
But as AppStore starts rejecting applications that use Udid, the MAC address returns the same value on all devices on the iOS7, and the restrictions on the Clipboard on iOS7, resulting in openudid not being able to share the same value with different apps. The above-mentioned IDs were doomed to leave the stage of history.
With IOS7 quickly taking over half of the time, the control of the device ID is finally back in Apple's hands, allowing users to take control of their privacy, fully demonstrating Apple's determination to protect users ' privacy.
Well, here's one question:What do we use to track and identify users in the iOS7 era?
Give the conclusion first
- IDFA: For external use: such as advertising, exchange, and other cross-application user tracking
- IDFV: For internal use: For example, analyzing user behavior within the app, etc.
PS: The dust settles, follow the Apple Walk, everybody no longer hesitate.
Explain IDFA again.
Idfv
The Heroes of History Udid
Device Unique identifier (unique device Identifier) before being a variety of domestic and foreign statistical platforms, application developers widely used, after Apple since May 01, 2013 refused to accept the use of UDID application, stand up!
MAC address
Each network card has a unique identity, that is, the MAC address, it is clearly used to identify a mobile phone is more than enough, there are some open source scheme also used it, domestic umtrack and so also used it as a master ID, with iOS7 return the same value, have to retire to the lake.
Openudid
After Apple refused to Udid, Openudid as an independent Apple-based open source program, was accepted by the vast number of developers, the major statistical advertising platform from Udid and other programs to switch to Openudid program (it seems that everyone does not want to be completely bound by Apple), but unfortunately, Also due to IOS7 's limitations on the Clipboard, the ability to share a single openudid on the same device can no longer be shared, that is, openudid is significantly weakened as a device's unique identity. You can also see that with the advent of iOS7, the advertising platform to quickly update their SDK, to switch to Apple's IDFA scheme.
Other
Cfuuid, Nsuuid and other self-generated, their own storage management is not elaborate.
Devicetoken
This is a push token, if the user does not push, or refused, this is not!
IOS6 and how to identify different devices in the future