UIDevice.IdentifierForVendor 属性

定义

基于App Store供应商或捆绑包标识符(如果不是来自App Store)的设备唯一标识符。

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual Foundation.NSUuid IdentifierForVendor { [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("identifierForVendor", ObjCRuntime.ArgumentSemantic.Strong)] get; }
member this.IdentifierForVendor : Foundation.NSUuid

属性值

属性

注解

对于来自同一供应商的所有应用,对于特定设备,此标识符是相同的。 此标识符在各设备中不同。

如果应用不是来自App Store,则根据捆绑 ID 计算设备的“供应商”。 在 iOS 7 及更高版本中,“供应商”基于捆绑 ID 的所有元素(最后一个组件除外)。 换句话说,如果捆绑 ID 为 com.mycompany.mydivision.app1,则“供应商”将计算为 com.mycompany.mydivision。 在 iOS 6 及以前版本中,“供应商”是从前两个组件计算的,因此捆绑 ID 为 com.mycompany.mydivision.app1 将基于 供应商 com.mycompany

方法 AsString() 通常用于提取实际标识,如以下示例所示:

var nsUid = UIDevice.CurrentDevice.IdentifierForVendor;
var guidElements = nsUid.AsString();
Console.WriteLine("ToString() : {0}\nAsString() : {1}", nsUid, guidElements);
/*
ToString() : <__NSConcreteUUID 0x79ef50> 959E8282-D65E-486C-B1D3-17D720CF668E
AsString() : 959E8282-D65E-486C-B1D3-17D720CF668E
*/              

这可以从后台线程使用。

适用于