iOS获取唯一标识

需要使用头文件

#import <CommonCrypto/CommonDigest.h>
-(NSString*) getDeviceID
{
    NSString * uId = [[UIDevice currentDevice].identifierForVendor UUIDString];
    const char *cStr = [uId UTF8String];
    if (cStr == NULL) {
        cStr = "";
    }
    unsigned char r[ CC_MD5_DIGEST_LENGTH ];
    CC_MD5(cStr,(CC_LONG)strLen([[NSString alloc] initWithUTF8String:cStr]),r);
    NSString *md5DeviceId = [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]]; return md5DeviceId; }

你可能感兴趣的:(ios,imie,唯一标识)