如何在 iOS 6 和 iOS 7 中获取 UDID
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13456996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the UDID in iOS 6 and iOS 7
提问by iDia
I want to get the device id and send it into a web service. How can I get the UDID
in iOS 6
我想获取设备 ID 并将其发送到 Web 服务中。我怎样才能UDID
在 iOS 6 中获得
Thanks
谢谢
回答by Wes Cossick
UDID is no longer available in iOS 6+ due to security / privacy reasons. Instead, use identifierForVendor
or advertisingIdentifier
.
由于安全/隐私原因,UDID 在 iOS 6+ 中不再可用。相反,请使用identifierForVendor
或advertisingIdentifier
。
identifierForVendor:
供应商标识符:
An alphanumeric string that uniquely identifies a device to the app's vendor. (read-only)
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.
一个字母数字字符串,用于向应用程序供应商唯一标识设备。(只读)
对于来自在同一设备上运行的同一供应商的应用程序,此属性的值是相同的。对于来自不同供应商的同一设备上的应用程序以及不同供应商的不同设备上的应用程序,将返回不同的值。
advertisingIdentifier:
广告标识符:
An alphanumeric string unique to each device, used only for serving advertisements. (read-only)
Unlike the identifierForVendor property of 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.
每个设备唯一的字母数字字符串,仅用于提供广告。(只读)
与 UIDevice 的 identifierForVendor 属性不同,向所有供应商返回相同的值。这个标识符可能会改变——例如,如果用户擦除设备——所以你不应该缓存它。
Thispost explains it well.
这个帖子解释的很好。
Also, see Apple's documentation for the identifierForVendor
and advertisingIdentifier
.
另外,请参阅 Apple 的文档identifierForVendor
和advertisingIdentifier
.
回答by Danoli3
Check out OpenUDID:
查看OpenUDID:
OpenUDID is a drop-in replacement for the deprecated uniqueIdentifier property of the UIDevice class on iOS (a.k.a. UDID) and otherwise is an industry-friendly equivalent for iOS and Android, and most recently Windows C# and Silverlight (see links above).
OpenUDID 是 iOS 上不推荐使用的 UIDevice 类的 uniqueIdentifier 属性(又名 UDID)的直接替代品,另外对于 iOS 和 Android 以及最近的 Windows C# 和 Silverlight(请参见上面的链接)是行业友好的等效项。
Edit: Make sure since May 1st 2013 for iOS 6 to use the thisBranch until the Main is updated:
编辑:确保自 2013 年 5 月 1 日起 iOS 6 使用此分支,直到更新 Main: