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

陌路散爱 提交于 2019-12-18 04:48:08

问题


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?


回答1:


Look here and then here




回答2:


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



来源:https://stackoverflow.com/questions/1460540/how-do-i-get-the-current-access-points-mac-address-bssid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!