How to get the wifi mac address on iPhone in Swift?

青春壹個敷衍的年華 提交于 2019-12-30 06:00:28

问题


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


回答1:


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.

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 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

Here's a nice reading about UDID




回答2:


This is no longer possible since iOS 7, due to privacy risks Apple does not allow developers to access any device specific identifiers.




回答3:


You can not get mac address because of some security concerns. you may use UUID instead to identify device uniquely.

for swift 4.2

UIDevice().identifierForVendor?.uuidString ?? ""

for objective c

[[[UIDevice currentDevice] identifierForVendor] UUIDString]


来源:https://stackoverflow.com/questions/29163110/how-to-get-the-wifi-mac-address-on-iphone-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!