问题
I am currently running Xcode 11.0 and iOS 13.1 (beta). I am experimenting with the newly added functionality in iOS 13 of being able to connect to Wifi hotspots where only the prefix is known: Apple Docs
This is perfect for headless accessory's Wifi setup, as you would not need to ask the user to switch to the OS settings in order to connect to the accessory's wifi.
But unfortunately I cannot make it work as expected.
My code (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")
}
}
}
Using the full name (e.g. "device-012"), it works:
let configuration = NEHotspotConfiguration.init(ssidPrefix: "device-012")
Am I missing something? Does the prefix-string maybe needs some wildcard pattern or so?
Thanks, Henry
回答1:
Not setting configuration.joinOnce = true
or setting it to false
makes it work.
A bug-report is already filed to Apple.
来源:https://stackoverflow.com/questions/58029300/ios-13-using-the-new-nehotspotconfiguration-initssidprefix-string-does-not-s