How to get MAC address?

How to get MAC address?
0.0 0


How to get MAC address?


That is very difficult to do correctly across all platforms.

Why do you want it anyway? It will change a lot more than you think.


Have a look at this code for iOS:

Here is a similar one on github:

If you target iOS 7 you should use the ASIdentifierManager:


because I want a unique identification like GUID for quick registration,is their any idea?


@shmilypyj: What do you have so far?


@Eschmelax I dont have any idea so far. I cannot create a GUID across all platforms. Or I may get a GUID from server,but this is my last choice.


this is my idea, not tested though but possible.
you get it from every platforms sdk but i dont know if windows phone sdk supports getting the mac address. also in ios7 above it doesnt support it anymore bec. the old way is deprecated now and they advice to use [UIDevice identifierForVendor]. but you can always check the ios version so you could invoke 2 different ways.


I read somewhere that using the (raw) UID of the devices are not allowed/illegal. So you might want to encrypt the UID you’re getting (so that you don’t save the actual device id) just to be safe.


@shmilypyj: Code will be different for every device/system you run on.

For example, in Windows, you’ll have to use Win32 API (CoCreateGUID):

As lance_gray pointed out, there might be legal issues.
Think the Apple HIG will be the first wall.


I see. thanks all.:slight_smile:


Just use cross bridging…call obj c from c++ and finally return the address back to cpp… I hope it will work then