iOS获取连接的wifi信息 iOS获取当前连接的wifi信息
大不不 人气:3导入框架CaptiveNetwork
#import <SystemConfiguration/CaptiveNetwork.h>
获取当前连接的wifi信息
// 只能获取当前的SSID - (id)fetchSSIDInfo { NSString *currentSSID = @""; CFArrayRef myArray = CNCopySupportedInterfaces(); if (myArray != nil){ NSDictionary* myDict = (__bridge NSDictionary *) CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0)); if (myDict!=nil){ currentSSID=[myDict valueForKey:@"SSID"]; } else { currentSSID=@"<<NONE>>"; } } else { currentSSID=@"<<NONE>>"; } NSArray *ifs = (__bridge id)CNCopySupportedInterfaces(); NSLog(@"%s: Supported interfaces: %@", __func__, ifs); id info = nil; for (NSString *ifnam in ifs) { info = (__bridge id)CNCopyCurrentNetworkInfo((CFStringRef)CFBridgingRetain(ifnam)); if (info && [info count]) { break; } } NSLog(@"wifi info %@",info); return info; }
wifi info { BSSID = "a4:2b:8c:92:47:3c"; SSID = "XF-WORLD"; SSIDDATA = <58462d57 4f524c44>; }
加载全部内容