每台 iPhone/iPod Touch 是否都有像 Mac 地址一样的唯一 ID?
我是否必须请求用户授予传输此类唯一 ID 的权限?
最佳答案
是的,您可以使用 UIDevice 的 uniqueIdentifier 属性来获取它:
A unique device identifier is a hash value composed from various hardware identifiers such as the device’s serial number. It is guaranteed to be unique for every device but cannot publically be tied to a user account. You can use it, for example, to store high scores for a game in a central server or to control access to registered products. The unique device identifier is sometimes referred to by its abbreviation UDID.
编辑: uniqueIdentifier 属性在 iOS5 中已弃用,您现在不应使用它。作为替代方案,您可以生成自己的唯一 ID(例如检查 this questions )。
此外,在 iOS6 中,Apple 添加了 2 个新方法来获取唯一标识符(作为 NSUUID 类的实例):
UIDevice -identifierForVendor:
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 onthe same device that come from different vendors, and for apps on different devices regardles of vendor.
ASIdentifierManager -advertisingIdentifier:
Unlike the identifierForVendor property of the UIDevice, the same value is returned to all vendors. This identifier may change—for example, if the user erases the device—so you should not cache it.
关于iphone - 每部 iPhone/iPod Touch 是否都有唯一的 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1476118/