How to get iOS device MAC address programmatically

iPhoneDeveloper picture iPhoneDeveloper · Feb 12, 2013 · Viewed 64.6k times · Source

How do I get an iOS device's MAC code programmatically in my app?

Answer

Nagendra Tripathi picture Nagendra Tripathi · Sep 20, 2013

Now iOS 7 devices – are always returning a MAC address of 02:00:00:00:00:00.

So better use [UIDevice identifierForVendor]

so better to call this method to get app specific unique key

Category will more suitable

#import "UIDevice+Identifier.h"

- (NSString *) identifierForVendor1
{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
        return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    }
    return @"";
}

Now call above method to get unique address

NSString *like_UDID=[NSString stringWithFormat:@"%@",
                [[UIDevice currentDevice] identifierForVendor1]];

NSLog(@"%@",like_UDID);