Search code examples
iphoneiosdevicemac-address

Returned mac-address is the same for different devices


I have to provide the unique identifier of my device to the server in a client app. Around StackOverflow it's been recommended commonly to use the device's mac address, since [[UIDevice currentDevice] uniqueIdentifier] property is deprecated started from iOS 5.

So, when I make attempt to retrieve a device's mac address following the instructions, provided in the answers around SO, I get the same address for both my devices, which is obviously wrong: 02:00:00:00:00:00.

Checked the code many times, but it seems to be correct. What could cause the problem of this sort?


Solution

  • Sorry guys, I was not attentive enough. When I was talking about the devices, I should mention that one of them was actually a simulator (with iOS 7), and the other was a device with iOS 7. So now I've found in the Apple documentation, that:

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

    So, identifierForVendor is exactly what I wanted. It's a pity though, that now in the code a developer should sort out different iOS versions support even for that thing.