zoukankan      html  css  js  c++  java
  • 获取Wi-Fi信息iOS

    获取Wi-Fi信息(名称、Mac 地址、信号强度)

    
    

    #import <SystemConfiguration/SystemConfiguration.h>

    #import <SystemConfiguration/CaptiveNetwork.h>



    -(NSString *)getWifiName { NSString *wifiName = nil; CFArrayRef wifiInterfaces = CNCopySupportedInterfaces(); if (!wifiInterfaces) { return @"unknow"; } 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);
    //
    networkInfo为一个字典,包含Wi-Fi名字、Mac 地址、信号强度

    wifiName
    = [networkInfo objectForKey:(__bridge NSString*)kCNNetworkInfoKeySSID];
    CFRelease(dictRef);
    }
    }
    CFRelease(wifiInterfaces);
    return wifiName;
    }

    在iOS9之后获取Wi-Fi相关信息,需要拥有对应权限的证书。

    xcode程序中也要打开capabilities中access wifi information开关

  • 相关阅读:
    JsonResponse
    python导出数据到excel
    ftp上传文件到服务器
    js设计模式 —— 订阅发布模式
    reducer的作用
    redux设置和使用三大原则
    js事件监听
    图片占位符
    正则练习
    正则基础
  • 原文地址:https://www.cnblogs.com/OIMM/p/14648993.html
Copyright © 2011-2022 走看看