用于标识iOS设备的各种方法。
UDID(Unique Device Identifier)
1
|
|
- UDID是可以唯一标识iOS设备的由40个16进制字符组成的序列。
- Available in iOS 2.0 – iOS 6.1;Deprecated in iOS 5.0.
- 自2013.5.1起,App Store不允许访问
UDID
的新应用提交。
IDFV(identifierForVendor) 开发商ID
用于应用的开发商(Vendor)唯一标识一台设备的ID。
1
|
|
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. Normally, the vendor is determined by data provided by the App Store. If the app was not installed from the app store (such as when the app is still in development), the vendor is determined based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format, and the first two components are used to generate a vendor ID. For example, com.example.app1 and com.example.app2 would appear to have the same vendor ID.
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. The value can also when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
- Available in iOS 6.0 and later.
- 对运行在同一台设备上的同一个开发商(Vendor)的所有App都返回同一个值。
- 对运行在同一台设备上的不同开发商(Vendor)的App返回不同的值。
- 对运行在不同设备上的App,不论开发商(Vendor),都返回不同的值。
- 从AppStore上下载的App,Vendor信息由AppStore中的数据决定。
- 不是从AppStore上下载的应用(例如开发中的应用),Vendor信息由app的bundle ID决定;bundle ID的前两部分用于 生成vendor ID,例如com.example.app1和com.example.app2会返回相同的vendor ID。
- 设备重启后、解锁前,vendor ID可能返回nil。
- 当同一个vendor的任意一个App在设备上存在时,vendor ID保持不变。当用户删除此vendor的所有App后,然后再次安装时vendor ID会 发生变化。
IDFA(Identifier for Advertisers)
用于广告统计的设备标识符。
1
|
|
- Available in iOS 6.0 and later.
- advertisingIdentifier
是
AdSupport.framework
框架的一部分。 几种情况下IDFA会变化
- 系统Reset(iOS7:Settings.app –> General –> Reset –> Reset All Content and Settings)
Reset Advertising Identifier(iOS7:Settings.app –> Privacy –> Advertising –> Reset Advertising Identifier)
Reset Advertising Identifier后,如果应用已经运行在后台,则返回应用后调用
advertisingIdentifier
并不会返回新的值,只有应用终止再启动才会返回新的值。
Limit Ad Tracking
设为ON
状态不影响advertisingIdentifier
的访问.- 访问了
advertisingIdentifier
但没有显示任何广告的App会被拒掉,见tapstream的blog。
Limit Ad Tracking
在Settings.app -> Privacy -> Advertising
设置有一项Limit Ad Tracking
,是否限制广告跟踪,目前这一选项没有实质性作用。
在开发文档中对advertisingTrackingEnabled
这样描述
Check the value of this property before performing any advertising tracking. If the value is NO, use the advertising identifier only for the following purposes: frequency capping, conversion events, estimating the number of unique users, security and fraud detection, and debugging.
advertisingTrackingEnabled
为NO,即Limit Ad Tracking
为’ON’状态;这只是设置一个标识告诉广告商(advertisers)不要使用
Advertising ID对用户进行针对性的广告匹配;但没有任何强制措施来保证这一点,对访问advertisingIdentifier
也没有任何限制。
Mac Address
在iOS之前可以获取设备的Mac地址做个MD5作为设备的唯一标识,但自iOS7起,获取Mac Address总是返回”02:00:00:00:00:00”
In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property ofUIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)
UUID(Universally Unique Identifiers)
UUID是可以在空间和时间范围内保证唯一性的128bit序列,由RFC 4122定义,微软的一个实现也叫做GUID(Globally Unique Identifier).
UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values A UUID is made unique over both space and time by combining a value unique to the computer on which it was generated and a value representing the number of 100-nanosecond intervals since October 15, 1582 at 00:00:00.
在iOS6中有NSUUID类来表示UUID,上面介绍的identifierForVendor
和advertisingIdentifier
返回值类型都是NSUUID。
也可以直接使用NSUUID
生成一个新的UUID,使用UUIDString
方法获取其字符串表示;
1 2 |
|
NSUUID
与Core Fundation的CFUUIDRef不是toll-free bridged的,不能直接进行转换。
需要使用UUID string在NSUUID
与CFUUID
间中转。
CFUUID
可在iOS5及之前的版本使用
1 2 |
|
OpenUDID
一个用于替换UDID的开源方案,不推荐使用
SecureUDID Deprecated
Crashlytics发布的开源沙盒UDID方案,现已废弃。