第三方库
SAMKeychain
IDFV:Vendor标示符 也被称为厂商标识符。只要用户设备中没有卸载当前Vendor的所以App ,则不会发生变化。什么是Vendor 可以理解成bundleID的前两部分,例如对于com.job.app_1和com.job.app_2这两个bundleID来说,就属于同一个Vendor,共享一个IDFV。
NSString * idfv = [UIDevice currentDevice] identfierForVendor] UUIDString];
IDFV比较适合追踪用户行为,目前配合Keychain来搭配使用。来保证不管是删除和重新安装 唯一标识不会变
NSString * sting = [self getUniqueDeviceIdentifierAsString];
NSLog(@" %@",sting);
-(NSString *)getUniqueDeviceIdentifierAsString
{
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *strApplicationUUID = [SAMKeychain passwordForService:appName account:@"incoding"];
if (strApplicationUUID == nil)
{
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSError *error = nil;
SAMKeychainQuery *query = [[SAMKeychainQuery alloc] init];
query.service = appName;
query.account = @"incoding";
query.password = strApplicationUUID;
query.synchronizationMode = SAMKeychainQuerySynchronizationModeNo;
[query save:&error];
}
return strApplicationUUID;
}