iOS---[UIDevice identifierForVendor]慎用!

An alphanumeric string that uniquely identifies a device to the app’s vendor. (read-only)

用于唯一标示设备的字母数字字符串,每一个供应商都不同呀


Declaration

OBJECTIVE-C

@property(nonatomic, readonly, strong) NSUUID *identifierForVendor

Discussion

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

对于运行于同一个设备,并且来自同一个供应商的所有App,这个值都是相同的。对于一个设备上来自不同供应商的app,这个值不同;不同设备的app,无论供应商相同与否,这个值都不同。


If the value is nil, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device.

如果此值为空,等一会再去获取。用户锁定设备后,再重启设备,此时获取为空,需要解锁。

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. 

当在设备上安装来自同一个供应商的不同App时,此值保持不变。如果你删除了来自某个供应商的所有app,再重新安装时,此值会改变。


请注意,这个属性只能在iOS6之后使用!


我使用iOS10.1.1测试,通过方法“

[[UIDevice currentDevice] identifierForVendor].UUIDString

”获取UUID,每次删除App后,重新获取的新值都不同的。

目前解决方法:获取一次后,使用钥匙串保存起来,这样即使你删除了App,再重新安装,只有BundleId不变,那么从钥匙串中获取的UUID不会变的。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值