iOS 12之前:
id info = nil;
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *ifnam in ifs) {
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSString *str = info[@"SSID"];//name
}
iOS 12之后以上方法获取不到,需要在Xcode中TARGET-->Capabilities打开Access WiFi Information选项

网友评论