【iOS开发】获取wifi的SSID

时间:2022-03-20 15:08:07
#import <SystemConfiguration/CaptiveNetwork.h>

NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();

    NSLog(@"Supported interfaces: %@", ifs);

    id info = nil;

    for (NSString *ifnam in ifs) {

        info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);

        NSLog(@"%@ => %@", ifnam, info);  //单个数据info[@"SSID"]; info[@"BSSID"];

        if (info && [info count]) { break; }

    }