前面两篇对IDFA简单地介绍了一下,这里根据这个文章(非常好)总结一下每处在代码中的简单实用方法:
http://www.ithao123.cn/content-8688001.html
1.UDID
iOS5以上代码被苹果禁掉了,相信很多人都会查看:
2.UUID
- (NSString *)getUID
{
return [[[NSUUID alloc] init] UUIDString];
}
3.MAC Adress
NSString * macaddr = [MacAddress GetMacAddress];
去Github找个算法
4.IDFA
+ (NSString *)getAdvertisingIdentify
{
NSString *idfa = @"";
if (VERSION_FLOAT >= 6.0)
{
ASIdentifierManager *idManager = [ASIdentifierManager sharedManager];
if ([idManager isAdvertisingTrackingEnabled])
{
idfa = [NSString stringWithFormat:@"%@",[[idManager advertisingIdentifier] UUIDString]];
}
}
return idfa;
}
5.IDFV
+ (NSString *)getIDFVString
{
NSString *idfv = @"";
if (VERSION_FLOAT >= 6.0)
{
idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
return idfv;
}
6.openUDID
附上Github地址:
https://github.com/ylechelle/OpenIDFA