众所周知,苹果已经于近期禁止使用设备UDID的应用上架,理由是用户个人隐私和行为习惯可能被恶意追踪。官方文档建议在iOS6以上版本中使用 identifierForVendor取代UDID,而在低版本iOS中使用CFUUID。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - (NSString *) idForDevice; {   NSString *result = @"";   UIDevice *thisDevice = [UIDevice currentDevice];   if ([thisDevice respondsToSelector: @selector(identifierForVendor)])   {     NSUUID *myID = [[UIDevice currentDevice] identifierForVendor];     result = [myID UUIDString];   }   else   {     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];     result = [defaults objectForKey: @"appID"];     if (!result)     {       CFUUIDRef myCFUUID = CFUUIDCreate(kCFAllocatorDefault);       result = (__bridge_transfer NSString *) CFUUIDCreateString(kCFAllocatorDefault, myCFUUID);       [defaults setObject: result forKey: @"appID"];       [defaults synchronize];       CFRelease(myCFUUID);     }   }   return result; } | 
 
																								