ios 如何唯一标识iOS设备而不是使用UUID和UDID
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30936371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to identify iOS device uniquely instead of using UUID and UDID
提问by Kirti Nikam
In my iOS app, I have to restrict the user to use iOS app per device. To do this I found a solution that we can use the UUID (Universally Unique Identifier)
or UDID (Unique Device Identifier)
. But according to this answerI can't use UUID, because if app gets deleted or reinstalled UUID
has been getting changed and I don't want this. Also Apple rejects apps if app uses UDID
.
在我的 iOS 应用程序中,我必须限制用户在每台设备上使用 iOS 应用程序。为此,我找到了一个解决方案,我们可以使用UUID (Universally Unique Identifier)
or UDID (Unique Device Identifier)
。但是根据this answer我不能使用UUID,因为如果应用程序被删除或重新安装UUID
已经被更改,我不想要这个。如果应用程序使用UDID
.
Is there any way to identify iOS device uniquely.
有什么方法可以唯一标识iOS设备。
回答by Vijay Tholpadi
回答by mgyky
I'm using this library for my projects, and it's working like a charm, please try :
我正在将这个库用于我的项目,它的工作非常吸引人,请尝试:
https://github.com/blackpixel/BPXLUUIDHandler
https://github.com/blackpixel/BPXLUUIDHandler
easy to use :
便于使用 :
Import BPXLUUIDHandler.h Retrieve the UUID with
导入 BPXLUUIDHandler.h 检索 UUID
[BPXLUUIDHandler UUID]
Thats all...
就这样...
Here is some info from project's github page :
以下是来自项目 github 页面的一些信息:
As of iOS 5, Apple has deprecated the device unique identifier api and hasn't provided a friendly Obj-C replacement, instead recommending CFUUIDCreate and NSUserDefaults.
CFUUIDCreate isn't very complicated and neither is NSUserDefaults, but this solution fails in a few different ways:
- It's not a quick one-shot call to get the UUID; you have to write your own wrapper to make it friendly
- It doesn't persist; deleting the app blows away the UUID (can be persisted if stored in the keychain though)
- There's no way to share it between apps
从 iOS 5 开始,Apple 已弃用设备唯一标识符 api 并且没有提供友好的 Obj-C 替代品,而是推荐 CFUUIDCreate 和 NSUserDefaults。
CFUUIDCreate 和 NSUserDefaults 都不是很复杂,但是这个解决方案在几个不同的方面失败了:
- 获取 UUID 不是一次性的快速调用;您必须编写自己的包装器以使其友好
- 它不会持续存在;删除应用程序会清除 UUID(如果存储在钥匙串中,则可以保留)
- 无法在应用程序之间共享它