Step1:
加入Framework: SystemConfiguration.Framework(在target -> summary -> Linked Frameworks and Libraries中加入)
Step2:
#import <SystemConfiguration/CaptiveNetwork.h>
Step3:
NSArray *ifs = (id)CNCopySupportedInterfaces(); //先取得所有網卡資訊
id info = nil;
NSString *wifiName = @"No SSID";
for (NSString *ifnam in ifs) {
info = (id)CNCopyCurrentNetworkInfo((CFStringRef)ifnam);
if (info && [info count]) {
//取得第一個有在用的網卡
NSDictionary *dic = (NSDictionary*)info; //取得網卡的資訊
wifiName = [dic objectForKey:@"SSID"]; //取得ssid
break;
}
[info release];
}
這樣就可以用了,容易吧 XD
參考網址:
iPhone get SSID without private library
iPhones OS: how to programmatically differentiate iPad 3G from iPad Wi-Fi?
沒有留言:
張貼留言