8

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?

2 Answers2

7

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

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
0

Look here and then here

Community
  • 1
  • 1
James
  • 5,812
  • 5
  • 26
  • 30
  • Thanks, that helps a lot. Is it also possible to get the BSSIDs of all available access points instead of only the one I'm currently connected to? –  Sep 22 '09 at 16:37
  • Thats what this will do - the NSDictionary networks contains a list of all the visible networks – James Sep 22 '09 at 18:37
  • I've found this post seeking for a way to get the access point MAC Address for a Wifi network. I'm a bit confused. Using this could cause that app will be rejected for app Store? – Rotten May 03 '11 at 15:00
  • 1
    Because its using a private API it'll get rejected. I mean you can try sneak it past them... – James May 04 '11 at 18:20
  • First link is dead. – Cinder Biscuits Oct 08 '18 at 01:46