Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 446
Vali Nagacevschi Avatar asked Mar 20 '15 09:03

Vali Nagacevschi


2 Answers

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

like image 137
Aluminum Avatar answered Oct 02 '22 15:10

Aluminum


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

like image 20
rckoenes Avatar answered Oct 02 '22 16:10

rckoenes