首先須要引入如下倆個框架框架
#import <SystemConfiguration/SystemConfiguration.h>get
#import <SystemConfiguration/CaptiveNetwork.h>string
+ (NSString *)getPhoneConnectedWifiName {io
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();class
// NSLog(@"%s: Supported interfaces: %@", __func__, ifs);import
id info = nil;object
for (NSString *ifnam in ifs) {bug
info = (__bridgeid)CNCopyCurrentNetworkInfo((CFStringRef)CFBridgingRetain(ifnam));im
if (info && [info count]) {co
break;
}
}
if ([info isKindOfClass:[NSDictionary class]]) {
// DDLogDebug(@"getPhoneConnectedWifiName:%@", [info objectForKey:@"SSID"]);
return [info objectForKey:@"SSID"];
}
return [NSString string];
}