我目前正在运行 Xcode 11.0 和 iOS 13.1(测试版)。我正在尝试 iOS 13 中新添加的功能,能够连接到仅已知前缀的 Wifi 热点:苹果文档
这非常适合无头配件的 Wifi 设置,因为您无需要求用户切换到操作系统设置即可连接到配件的 WiFi。
但不幸的是我无法让它按预期工作。
我的代码(Swift 5):
if #available(iOS 13, *) {
// The accessory's wifi name starts with "device-", followed by 3 digit number, e.g. "device-012"
let configuration = NEHotspotConfiguration.init(ssidPrefix: "device-")
configuration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if error != nil {
if error?.localizedDescription == "already associated."
{
print("Connected")
}
else {
print("No Connected")
}
}
else {
print("Connected")
}
}
}
使用全名(例如“device-012”),它的工作原理是:
let configuration = NEHotspotConfiguration.init(ssidPrefix: "device-012")
我错过了什么吗?前缀字符串是否可能需要一些通配符模式等等?
谢谢,
亨利
未设置configuration.joinOnce = true
或将其设置为false
让它发挥作用。
错误报告已提交给 Apple。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)