如何在Swift上获取iPhone上的wifi mac地址? [英] How to get the wifi mac address on iPhone in Swift?

查看:1056
本文介绍了如何在Swift上获取iPhone上的wifi mac地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用Swift语言获取IOS设备的真实Wi-Fi MAC地址?
代码片段非常感谢!
谢谢。

Is there a way to get the real Wi-Fi MAC address of the IOS device using Swift language? Code snippet much appreciated! Thanks.

推荐答案

当您在iOS 7及更高版本中请求设备MAC地址时,您将始终获得相同的响应: 02:00:00:00:00:00 ,这是由 Apple 出于隐私考虑。

When you request the Device MAC address in iOS 7 and above you will always get the same response: 02:00:00:00:00:00, this has been made by Apple for privacy concerns.


在iOS 7及更高版本中,如果您要求提供iOS设备的MAC地址,系统将返回值02:00:00:00:00:00。如果需要识别设备,请使用UIDevice的identifierForVendor属性。 (需要为自己的广告目的使用标识符的应用应考虑使用ASIdentifierManager的advertisingIdentifier属性。)

In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)

Apple建议切换到 UDID ,而不是您需要唯一标识iOS设备。在 Swift 中,您可以使用:

Apple recommends to switch to UDID instead if you need to uniquely identify an iOS device. In Swift you can use this:

UIDevice.currentDevice().identifierForVendor

如果你想要一个字符串而不是:

if you want a string instead use:

UIDevice.currentDevice().identifierForVendor.UUIDString

这里是一本关于UDID的好读物

Here's a nice reading about UDID

这篇关于如何在Swift上获取iPhone上的wifi mac地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆