Hi,
I have noticed an issue with the NEHotspotConfigurationManager.
I tested using iphone 8 plus.
using the following code
let configuration = NEHotspotConfiguration.init(ssid: "SSIDname", passphrase: "Password", isWEP: false)
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")
}
}
it returns "Not Connected", but if you observer the phones screen you see that the wifi does in fact connect to the network a second or two after.
could someone let me now if they also see this? I made sure to "forget" the network details before running this.
Thank you
To understand what’s going on here you need to understand a little bit about how this API works.
NEHotspotConfigurationManager
is a high-level API for managing configurations but the actual work to join the Wi-Fi network is done by the system’s underlying Wi-Fi infrastructure.
NEHotspotConfigurationManager
calls its completion handler as soon as it has dealt with the request, that is, as soon as it has checked the request and passed it on to that Wi-Fi infrastructure. This has a significant impact on users of
NEHotspotConfigurationManager
:
You can’t be guaranteed that the device has actually joined the Wi-Fi network by the time your completion handler is called. In fact this won’t be the case most of the time.
If there’s an error joining the Wi-Fi network, that error is reported to the user, not via your completion handler.
If these behaviours cause problems for you in practice — and I can totally see how they might — you should feel free to file a bug report (or enhancement request, depending on your perspective :-) against
NEHotspotConfigurationManager
describing the problem and the behaviour you’d like to see.
Please post your bug number, just for the record.
Finally, even once the device has joined the Wi-Fi network, it can still take time for it to get an IP address, meaning you won’t necessarily be able to communicate over the Wi-Fi network for a while. In your other thread I suggested that you use Bonjour to find your accessory, and this is one of the reasons why. Once the device has joined the accessory’s Wi-Fi network and got an IP address, Bonjour will automatically find your accessory’s service. If you don’t use Bonjour then you have to deal with all of that complexity yourself.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"