我可以用什么长期方法来唯一识别iOS设备?

ris*_*shi 19 iphone objective-c ios

唯一注册iOS设备的最佳方式是什么,不受Apple未来限制的限制?

我目前注册iOS设备的方法(基本上是唯一地识别设备)是我使用iOS设备的UDID来识别并注册它,然后在识别之后我执行必要的操作.

问题是不推荐使用UIDevice uniqueIdentifier属性.我知道有一些解决方法(正如本问题中所讨论的).

一种可能性是使用iOS设备的MAC地址.但是,我觉得Apple可能会在将来的某个时候限制访问这些信息.

有没有其他方法(除了访问MAC地址)识别iOS设备,我们可以依赖它?

roo*_*117 7

使用Apple首选的生成CFUUIDRef的方法可能是更好的解决方案,因为我觉得将来也可能会删除MAC地址.如果你使用它并将其保存到NSUserdefaults,除非用户删除应用程序,否则你将保持它.如果您想拥有一个可以在应用程序之间共享的生成的唯一ID,或者在安装之间保留,您应该查看使用UIPasteboard并使用您在应用程序之间共享的密钥保存生成的UID.

//Create a unique id as a string
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);

//create a new pasteboard with a unique identifier
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"youruniquestring" create:YES];

[pasteboard setPersistent:YES];

//save the unique identifier string that we created earlier
[pasteboard setString:((__bridge NSString*)string)];


 //accessing it
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"youruniquestring" create:NO];
NSLog([pasteboard string]);
Run Code Online (Sandbox Code Playgroud)

我在这里写了一个简短的教程,但基本上是以上几行:http://www.roostersoftstudios.com/2012/03/26/a-way-to-share-data-between-apps-on-a-given- IOS-设备/


she*_*ein -2

使用设备的 Mac 地址。我认为它非常独特。

如何以编程方式获取 iPhone 的 MAC 地址