我正在研究需要获取手机wifi路由器制造商名称(例如Kasda Network Inc或Huawei Technologies co。ltd)的应用程序。这里的app显示了以下供应商名称。 我如何获得有关以下供应商的确切信息
答案 0 :(得分:1)
问题包括两个部分。
1:如何获取已连接的wifi的Mac地址
2:基于该Mac地址获取制造商名称
1:获取Mac地址
func getConnectedWifiMacAdrees()-> [String:String]{
var informationDictionary = [String:String]()
let informationArray:NSArray? = CNCopySupportedInterfaces()
if let information = informationArray {
let dict:NSDictionary? = CNCopyCurrentNetworkInfo(information[0] as! CFString)
if let temp = dict {
informationDictionary["BSSID"] = String(temp["BSSID"]as!String)
return informationDictionary
}
}
return informationDictionary
}
注意:: import SystemConfiguration.CaptiveNetwork
下载最新的制造商数据。答案 1 :(得分:0)
尝试
import SystemConfiguration.CaptiveNetwork
func getSSID() -> String? {
let interfaces = CNCopySupportedInterfaces()
if interfaces == nil {
return nil
}
let interfacesArray = interfaces as! [String]
if interfacesArray.count <= 0 {
return nil
}
let interfaceName = interfacesArray[0] as String
let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName as CFString)
if unsafeInterfaceData == nil {
return nil
}
let interfaceData = unsafeInterfaceData as! Dictionary <String,AnyObject>
return interfaceData["SSID"] as? String
}