![](/img/trans.png)
[英]iOS 13: Network connected via NEHotspotConfiguration disconnects after a few seconds
[英]iOS 13: Using the new NEHotspotConfiguration.init(ssidPrefix: String) does not seem to work
我目前正在运行 Xcode 11.0 和 iOS 13.1(测试版)。 我正在试验 iOS 13 中新增的功能,即能够连接到仅知道前缀的 Wifi 热点: Apple Docs
这非常适合无头配件的 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 提交错误报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.