在iOS 4.x中,有一些关于我的要求的API,但是在5.x中它似乎变成了私有,在6.x中它似乎已被删除。 (实际上似乎无法在沙箱中调用)

获取802.11的SSID列表对于我们的新项目非常重要。

最佳答案

此代码可以很好地获得SSID。

#import <SystemConfiguration/CaptiveNetwork.h>

@implementation IODAppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSLog(@"Connected at:%@",myDict);
NSDictionary *myDictionary = (__bridge_transfer NSDictionary*)myDict;
NSString * BSSID = [myDictionary objectForKey:@"BSSID"];
NSLog(@"bssid is %@",BSSID);
// Override point for customization after application launch.
return YES;
}


这是结果:

Connected at:{
BSSID = 0;
SSID = "Eqra'aOrange";
SSIDDATA = <45717261 27614f72 616e6765>;


}

关于iphone - 如何获取iOS6的可用SSID列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15468387/

10-10 03:15