我想获取所有可用的wifi网络iphone。 我使用此代码
import SystemConfiguration
import SystemConfiguration.CaptiveNetwork
func fetchSSIDInfo() -> String {
var currentSSID = ""
if let interfaces = CNCopySupportedInterfaces() {
for i in 0..<CFArrayGetCount(interfaces) {
let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interfaces,i)
let rec = unsafeBitCast(interfaceName, to: AnyObject.self)
print("teseeeeeeeee :\(rec)")
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString)
if let interfaceData = unsafeInterfaceData as? [String: AnyObject] { currentSSID = interfaceData["SSID"] as! String
let BSSID = interfaceData["BSSID"] as! String
let SSIDDATA = interfaceData["SSIDDATA"]
debugPrint("ssid=\(currentSSID), BSSID=\(BSSID), SSIDDATA=\(SSIDDATA)")}}} return currentSSID}
此显示在currentssid中,我想获取所有wifi ssid
答案 0 :(得分:0)
你不能,
如果您使用NEHotspotHelper,则它不是作为通用Wi-Fi扫描API设计的,因此尝试使用它会遇到业务和技术问题。
阅读此https://www.samba.org/samba/docs/using_samba/ch09.html#samba2-CHP-9-TABLE-1也请参阅article