iOS获取当前连接的WiFi名称
2016-08-12 本文已影响0人
KKFantasy
#import <SystemConfiguration/CaptiveNetwork.h>
+ (NSString *)SSID {
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
NSLog(@"%s: Supported interfaces: %@", __func__, interfaceNames);
NSDictionary *SSIDInfo;
for (NSString *interfaceName in interfaceNames) {
SSIDInfo = CFBridgingRelease(
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
NSLog(@"%s: %@ => %@", __func__, interfaceName, SSIDInfo);
BOOL isNotEmpty = (SSIDInfo.count > 0);
if (isNotEmpty) {
break;
}
}
NSString *SSID = SSIDInfo[@"SSID"];
return SSID;
}