1. 引入头,#import <SystemConfiguration/CaptiveNetwork.h>
2. 获取SSID info
+ (id)fetchSSIDInfo
{
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
id info = nil;
for (NSString *ifnam in ifs) {
info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
if (info && [info count]) {
break;
}
}
return info;
}
3. 调用
NSDictionary *ifs = [AppDelegate fetchSSIDInfo];
NSString *ssid = [[ifs objectForKey:@"SSID"] lowercaseString];
NSLog(@"ssid:%@",ssid);
4.此框架介绍可参照此link http://bobffin.wordpress.com/2013/12/30/ios-captivenetwork-api-的用法/
时间: 2024-09-30 21:57:41