配合钥匙串使用
UDID (已禁用)
- 40个字符:2b8790c160444bce476a4ffd2aade531debf8de5
MAC地址(已禁用)
- 6个字节共48位,每个字节用两个十六进制数来表示:02:00:00:00:00:00
IDFA:同一个设备上所有APP获取到的是同一个值,苹果提供给广告商追踪广告的,需要引入AdSupport.framework框架,并且需要用户允许广告追踪,所以一般会通过运行时来获取避免SDK依赖
- 98242C4C-21D6-409E-BB52-E45907F0E0E9
IDFV:同一个提供商下的应用获取到的值都是一样的,通过BundleID的反转的前两部分进行匹配,如果相同就是同一个Vendor,例如对于com.abc.app1, com.abc.app2 这两个BundleID来说,就属于同一个Vendor,共享同一个IDFV的值
- 982220D4-7D1E-485E-B437-22094AF6DA9A
NSUUID:
- 0FA9829F-ECF3-4582-A7AC-1E9075A59A0C
+ (NSString *)getDeviceID {
NSString *distinctId = NULL;
Class ASIdentifierManagerClass = NSClassFromString(@"ASIdentifierManager");
if (ASIdentifierManagerClass) {
SEL sharedManagerSelector = NSSelectorFromString(@"sharedManager");
id sharedManager = ((id (*)(id, SEL))[ASIdentifierManagerClass methodForSelector:sharedManagerSelector])(ASIdentifierManagerClass, sharedManagerSelector);
SEL advertisingIdentifierSelector = NSSelectorFromString(@"advertisingIdentifier");
NSUUID *uuid = ((NSUUID * (*)(id, SEL))[sharedManager methodForSelector:advertisingIdentifierSelector])(sharedManager, advertisingIdentifierSelector);
distinctId = [uuid UUIDString];
// 在 iOS 10.0 以后,当用户开启限制广告跟踪,advertisingIdentifier 的值将是全零
// 00000000-0000-0000-0000-000000000000
if (!distinctId || [distinctId hasPrefix:@"00000000"]) {
distinctId = NULL;
}
}
// 没有IDFA,则使用IDFV
if (!distinctId && NSClassFromString(@"UIDevice")) {
distinctId = [[UIDevice currentDevice].identifierForVendor UUIDString];
}
// 没有IDFV,则使用UUID
if (!distinctId) {
// SADebug(@"%@ error getting device identifier: falling back to uuid", self);
distinctId = [[NSUUID UUID] UUIDString];
}
return distinctId;
}
网友评论