#define SYSTEM_VERSION_MORE_THAN_BFDATA(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)+ (NSString *)advertisingID { NSString *returnValue = nil; if (SYSTEM_VERSION_MORE_THAN_BFDATA(@"5.9")) {//通过抽象类来获取 ASIdentifier 这里面的方法。得到idfa Class MyManager = NSClassFromString(@"ASIdentifierManager"); if (MyManager) { id manager = [MyManager performSelector:@selector(sharedManager)]; if ([manager performSelector:@selector(isAdvertisingTrackingEnabled)]) { returnValue = [[manager performSelector:@selector(advertisingIdentifier)] performSelector:@selector(UUIDString)]; } } } return returnValue;}