获取Wi-Fi信息(名称、Mac 地址、信号强度)#import SystemConfiguration/SystemConfiguration.h#import SystemConfiguration/CaptiveNetwork.h-(NSString *)getWifiName{NSString *wifiName = nil;CFArrayRe...
获取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开关
沃梦达教程
本文标题为:获取Wi-Fi信息iOS
猜你喜欢
- Android实现监听音量的变化 2023-03-30
- 作为iOS开发,这道面试题你能答出来,说明你基础很OK! 2023-09-14
- 最好用的ios数据恢复软件:PhoneRescue for Mac 2023-09-14
- iOS 对当前webView进行截屏的方法 2023-03-01
- Android studio实现动态背景页面 2023-05-23
- Android实现轮询的三种方式 2023-02-17
- 详解flutter engine 那些没被释放的东西 2022-12-04
- SurfaceView播放视频发送弹幕并实现滚动歌词 2023-01-02
- Android MaterialButton使用实例详解(告别shape、selector) 2023-06-16
- Flutter实现底部和顶部导航栏 2022-08-31