我正在尝试使用 NEHotspotConfiguration 以编程方式连接(请参阅下面的代码)。但是,当我尝试连接时,错误提示:“无效的 WPA/WPA2 密码长度”,但我连接的是开放网络,不需要密码。
我已经看到了一些解决方案,但由于质量原因,我无法使用许多解决方法。
let wifiConfig = NEHotspotConfiguration(ssid: SSID, passphrase: "", isWEP: false)
wifiConfig.joinOnce = false
NEHotspotConfigurationManager.shared.apply(wifiConfig) { error in
if let error = error{
print("Error: " + (error.localizedDescription))
}else {
print("Connected.")
}
}
我能做些什么来修复它?
最佳答案
开放网络有一个特定的 API。看着 API docs for NEHotspotConfiguration看起来你应该使用 init(ssid: String)
而不是 init(ssid: String, passphrase: String, isWEP: Bool)
关于ios - 连接到 SSID 时 Swift 密码短语无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47912947/