加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在Swift中获取唯一的设备ID?

发布时间:2020-12-14 06:12:02 所属栏目:百科 来源:网络整理
导读:如何在Swift中获取设备唯一ID? 我需要一个ID在数据库中使用,并作为我的社交应用程序中的Web服务的API密钥。跟踪此设备的日常使用,并限制其查询到数据库。 谢谢! 你可以使用这个(Swift 3): UIDevice.current.identifierForVendor!.uuidString 对于较旧版
如何在Swift中获取设备唯一ID?

我需要一个ID在数据库中使用,并作为我的社交应用程序中的Web服务的API密钥。跟踪此设备的日常使用,并限制其查询到数据库。

谢谢!

你可以使用这个(Swift 3):
UIDevice.current.identifierForVendor!.uuidString

对于较旧版本:

UIDevice.currentDevice().identifierForVendor

或者如果你想要一个字符串:

UIDevice.currentDevice().identifierForVendor!.UUIDString

在用户卸载应用程序后,不再有唯一标识设备的方法。文档说:

The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

您也可以阅读Mattt Thompson的这篇文章,了解更多详情:
http://nshipster.com/uuid-udid-unique-identifier/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读