可能重复: iOS唯一用户标识符
对于我的申请,我需要电话uuid。我知道我可以用
NSUUID *uuid = [NSUUID UUID];但是每次我重新启动应用程序时,我都会收到不同的值。所以我不能像以前的uuid那样使用它(它总是一样的)。
我能做些什么来接收稳定和唯一的标识符?
发布于 2012-12-22 15:07:59
您正在考虑的是UDID (而不是UUID),它已被废弃,不再允许在App上使用。
下面是一种模拟它的技术:https://stackoverflow.com/a/8677177/832111
发布于 2012-12-22 15:07:33
UUID是128位值,UUID在空间和时间上都是唯一的,它结合了生成UUID的计算机的唯一值和表示自1582年10月15日00:00的100纳秒间隔的值。
所以每一秒你都会得到一个新的UUID。
您不能接收稳定和唯一的id,相反,您可以将接收到的id保存在密钥链或plist中并使用它。
发布于 2012-12-22 15:33:47
您可以使用OpenUDID库为每个设备生成唯一的UDID。它是可用的这里。从根本上说,它使用的是纸板。下面是一个例子
//First app, install->run->close->delete
UIPasteboard* board = [UIPasteboard pasteboardWithName:@"com.company.wtv" create:YES];
board.persistent=YES;// persistent to make what you write persist after your app closes, or gets deleted.
[board setValue:@"hello" forPasteboardType:@"com.company.wtv.sharedValue"];
//Second app, installed after first one is deleted and ran this one... While bundle identifier and bundle seed different (i tried it on adhoc, not really releasing the app, but i htink the same)
NSData* result=nil;
NSString*resultStr=nil;
result =[board valueForPasteboardType:@"com.company.wtv.sharedValue"];
resultStr=[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];// I got resultStr containing hellohttps://stackoverflow.com/questions/14003865
复制相似问题