美文网首页
iOS获取当前连接的WiFi名称

iOS获取当前连接的WiFi名称

作者: KKFantasy | 来源:发表于2016-08-12 12:57 被阅读0次
    #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;
    }
    

    参考链接:
    iPhone get SSID without private library

    相关文章

      网友评论

          本文标题:iOS获取当前连接的WiFi名称

          本文链接:https://www.haomeiwen.com/subject/ietesttx.html