14

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

Vali Nagacevschi
  • 152
  • 1
  • 1
  • 7
  • [Relevant Link](http://stackoverflow.com/questions/16470615/is-it-possible-to-get-the-ssid-mac-address-of-currently-connected-wifi-network) – Bista Mar 20 '15 at 10:06

4 Answers4

27

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

Aluminum
  • 2,932
  • 5
  • 35
  • 63
5

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

rckoenes
  • 69,092
  • 8
  • 134
  • 166
5

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]
Aqeel Ahmad
  • 709
  • 7
  • 20
0

For iOS 15 do this:

UIDevice.current.identifierForVendor?.uuidString
Dev Doshi
  • 160
  • 2
  • 12