在swift中获取wifi信息

发布时间:2024-09-05 10:36:13

项目管理系统中开发了 考勤功能,使用的是wifi作为考勤设备 所以我们就获得wifi的信息 我们使用的开源框架是:FGRoute

1.pod install

pod 'FGRoute'

2.导入模块 在相应的Swift类中

import FGRoute

3.使用

FGRoute.isWifiConnected() //判断是否链接的是wifi
FGRoute.getSSID()! //wifi的名称
FGRoute.getBSSID()! //wifi设备的唯一编码

let bssid=FGRoute.getBSSID()
if(nil != bssid){//虚拟机中无法取得这个数据 但发觉苹果的上线测试应该是用的虚拟机 不判断可能会出现闪退

需要在info.plist中声明权限

NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationUsageDescription
NSLocationWhenInUseUsageDescription

直接写入的方式

	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>描述</string>
	<key>NSLocationUsageDescription</key>
	<string>描述</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>描述</string>

Card image cap
APP STORE
Card image cap
应用宝
Card image cap
小米
Card image cap
华为