我可以使用什么长期方法来唯一标识iOS设备? [英] What is a long-term method I can use to uniquely identify an iOS device?

查看:111
本文介绍了我可以使用什么长期方法来唯一标识iOS设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the best way to uniquely register an iOS Device, which won't be limited by future Apple restrictions?

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

My current approach to register an iOS device (basically to identify the device uniquely) is that I use the UDID of an iOS device to identify it and register it, and then after recognising it I perform the necessary actions.

问题是不推荐使用UIDevice uniqueIdentifier属性。有一些解决方法(如此问题中所述)我知道。

The issue is that the UIDevice uniqueIdentifier property is deprecated. There are certain workarounds for that (as discussed in this question) which I'm aware of.

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

One possibility is to use the MAC address of an iOS device. However, I feel that Apple may restrict access to this information at some point in the future, as well.

除了访问MAC地址之外,还有其他办法吗?识别我们可以依赖的iOS设备?

Is there any other way (besides accessing the MAC address) to identify an iOS device, which we can rely on for the future?

推荐答案

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

Using Apple's preferred method of generating a CFUUIDRef is probably the better solution as I feel the MAC address may be removed in the future as well. If you use this and save it to your NSUserdefaults you will have it persist unless the user deletes the app. If you want to have a generated unique ID that you can share between apps or persist between installs you should look at using the UIPasteboard and saving your generated UID with a key that you share between apps.

//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]);

我在这里写了一个简短的教程,但基本上是上面的几行:http://www.roostersoftstudios.com/ 2012/03/26 / a-way-to-share-app-between-a-given-ios-device /

I have written a brief tutorial here but its basically the lines above: http://www.roostersoftstudios.com/2012/03/26/a-way-to-share-data-between-apps-on-a-given-ios-device/

这篇关于我可以使用什么长期方法来唯一标识iOS设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆