ios WiFi

真机上测试

- (id)fetchSSIDInfo {

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

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

id info = nil;

for (NSString *ifnam in ifs) {

info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));

if (info && [info count]) {

break;

}

}

return info;

}

- (NSString * )currentWifiSSID {

//    Does not work on the simulator.

NSString *ssid = nil;

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

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

for (NSString *ifnam in ifs) {

NSDictionary *info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));

NSLog(@"dici:%@",[info  allKeys]);

if (info[@"SSIDD"]) {

ssid = info[@"SSID"];

}

}

return ssid;

}

你可能感兴趣的:(ios WiFi)