获取手机唯一标识码

看到获取UDID,在IOS5.0已经过时了,原文说明
------------------------------------------------------------------------------------------------------------
Deprecated in iOS 5.0

uniqueIdentifier
An alphanumeric string unique to each device based on varioushardware details. (read-only) ( Deprecated in iOS 5.0. Instead,create a unique identifier specific to your app.)

@property (nonatomic, readonly, retain) NSString*uniqueIdentifier
Special Considerations
Do not use the uniqueIdentifier property. To create a uniqueidentifier specific to your app, you can call the CFUUIDCreate function to create aUUID, and write it to the defaults database using theNSUserDefaults class.

Availability
Available in iOS 2.0 and later.
Deprecated in iOS 5.0.
Related Sample Code
GKTank
Declared In
UIDevice.h
------------------------------------------------------------------------------------------------------------

经高手指点使用

   CFUUIDRef uuid = CFUUIDCreate(NULL);
   CFStringRef uuidStr = CFUUIDCreateString(NULL,uuid);
   NSString *strUid = [NSStringstringWithFormat:@"%@",uuidStr];
   CFRelease(uuidStr);
   CFRelease(uuid);


也可参考
http://maniacdev.com/2011/08/open-source-unique-device-id-generator-for-udid-alternative/
上面链接的例子:
https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5

Description
Apple stopped supporting a unique identifier for iOS. This sourcecode solves the problem. It generates a unique identifier based onthe mac address of the device in combination with the bundleidentifier.

What you need to do:
copy NSString+MD5Addition and UIDevice+IdentifierAddition to yourproject.
use [[UIDevice currentDevice] uniqueDeviceIdentifier] to retrievethe unique identifier or
use [[UIDevice currentDevice] uniqueGlobalDeviceIdenti
fier] toretrieve a global unique identifier (used for tracking betweendifferent apps).
have fun and follow twitter.com/gekitz ;)
//Thanks to Erica Sadun for her UIDevice+Hardware Addition (usedfor the mac address retrieval).

拷贝 NSString+MD5Addition 和UIDevice+IdentifierAddition到你的项目,使用
[[UIDevice currentDevice]uniqueDeviceIdentifier] 
[[UIDevice currentDevice]uniqueGlobalDeviceIdentifier]
就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值