iOS中如何获取手机连接到wifi名

        

#pragma mark 获取wifi名

+ (NSString *)getWifiName

{

    NSString *wifiName = nil;

    

    CFArrayRef wifiInterfaces = CNCopySupportedInterfaces();

    

    if (!wifiInterfaces) {

        return nil;

    }

    

    NSArray *interfaces = (__bridge NSArray *)wifiInterfaces;

    

    for (NSString *interfaceName in interfaces) {

        CFDictionaryRef dictRef = CNCopyCurrentNetworkInfo((__bridge CFStringRef)(interfaceName));

        

        if (dictRef) {

            NSDictionary *networkInfo = (__bridge NSDictionary *)dictRef;

            NSLog(@"network info -> %@", networkInfo);

            wifiName = [networkInfo objectForKey:(__bridge NSString *)kCNNetworkInfoKeySSID];

            

            CFRelease(dictRef);

        }

    }

    

    CFRelease(wifiInterfaces);

    return wifiName;

}

原文地址:https://www.cnblogs.com/zxh-iOS/p/5237638.html