How do I get the current access point's MAC address/BSSID?

Deniz picture Deniz · Sep 22, 2009 · Viewed 12.7k times · Source

My iPhone is connected to an access point through a WiFi connection. Does anybody now how I can retrieve this Access Point's MAC address with Objective-C?

Answer

Durai Amuthan.H picture Durai Amuthan.H · Dec 30, 2013

It works for me

  • Add SystemConfiguration.framework

  • import < SystemConfiguration/CaptiveNetwork.h>

  • use the below method

     +(NSString *)currentWifiBSSID {
    
            NSString *bssid = nil;
            NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
            for (NSString *ifnam in ifs) {
                NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
    
                NSLog(@"info:%@",info);
    
                if (info[@"BSSID"]) {
                    bssid = info[@"BSSID"];
                }
            }
            return bssid;
        }
    

Any usage of this code won't get your app rejected by Apple.

To know more about the Captive Network API click here