[IOS] user identification methods available for iOS8 (idfa, UUID, idfv)

Source: Internet
Author: User
Tags key string reverse dns

[IOS] user identification methods available for iOS8 (idfa, UUID, idfv)


To track and count users, you naturally need a Unique User Identifier, which is a problem facing every company. There are many unique identifiers in history, such as UDID, MAC address, and OpenUDID. I will not describe how they got down one by one, but now only idfa, idfv, UUID + keyChain are useful.


Idfa (Advertising Identifier): It can be understood as an advertisement id, which apple provides to track users.

Disadvantage: You can set-privacy-advertisement-Restore ad identifier to restore, and then get a new identifier;

IOS> = 6.0.


  #import   NSString *idfa= [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

Idfv (identifierForVendor): The unique identifier provided by apple to Vendor. Vendor represents the application developer. In actual use, a Vendor is the first two parts of CFBundleIdentifier (reverse DNS format. For example, the idfv obtained by com. baidu. tieba and com. baidu. image are the same, because the first two parts of their CFBundleIdentifier are the same.

Disadvantage: After all the applications of the same developer are uninstalled, The idfv obtained by re-installation will be different. Assume that the mobile phone is installed with two company apps,

Requirements: iOS & gt; = 6.0


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


UUID (Universally Unique Identifier): A universal unique identifier. Each generation is different. Therefore, the key string must be saved after the first generation, so that the key string can be obtained even if the application is deleted and reinstalled.


There are many UUID generation methods. Only one is written here. Generate a UUID:


-(NSString*) uuid {    CFUUIDRef puuid = CFUUIDCreate( nil );    CFStringRef uuidString = CFUUIDCreateString( nil, puuid );    NSString * result = (NSString *)CFBridgingRelease(CFStringCreateCopy( NULL, uuidString));    CFRelease(puuid);    CFRelease(uuidString);    return result;}
Store UUID in the key string. A third-party tool SFHFKeychainUtils is used here. github address



 [SFHFKeychainUtils storeUsername:@UDID andPassword:[self uuid] forServiceName:@ZYB updateExisting:1 error:nil];
Remove UUID from the key string:



[SFHFKeychainUtils getPasswordForUsername:@UDID andServiceName:@ZYB error:nil]

NOTE: If no storage is available, crash will be taken out directly.



Related Article

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.