苹果手机获取设备唯一UDID号

本来可以用下面的代码轻松获取UDID号:

NSString *uuid = [[UIDevice currentDevice] uniqueIdentifier];

不过iOS5后, uniqueIdentifier 这个函数被废除了, 编译不过去。

只能另外想办法。


网上找了一下, 有可以替代的方案,这个方案还是比较靠谱的。


该解决方案源码地址:

https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5

该方案提供了两个方法:

uniqueDeviceIdentifier (返回MAC和CFBundleIdentifier的MD5值)
uniqueGlobalDeviceIdentifier(返回MAC的MD5值)

 
使用方法:

#import "UIDevice+IdentifierAddition.h"

NSLog(@"%@",[[UIDevice currentDevice] uniqueDeviceIdentifier]);
NSLog(@"%@",[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]);

 苹果手机获取设备唯一UDID号_第1张图片

还有就是OpenUDID开源库的方案, 不过这个方案我下载后, 在我的IOS7上编译不过去, 最后没有使用。

OpenUDID下载地址:https://github.com/ylechelle/OpenUDID


还有一个方案叫 SecureUDID, 没有使用过。

SecureUDID下载地址:https://github.com/crashlytics/secureudid



希望对大家有用。

你可能感兴趣的:(苹果手机获取设备唯一UDID号)