My iOS app needs to connect to an IOT device Wi-Fi, which does not have internet access. iOS app already knows the ssid password of the iOT device Wi-Fi.
So I tried connecting to IOT device Wi-Fi using [NEHotspotConfigurationManager applyConfiguration] API. The issue is that my app fails to join IOT device Wi-Fi in the first attempt. It connects on second attempt. I have verified that IOT wifi was enabled and availble in Wi-Fi list in Settings > Wi-Fi
In code, error in applyConfiguration callback is nil, indicating success, so I check for connected Wi-FI SSID using CNCopyCurrentNetworkInfo As SSID is different (other network) from my IOT device Wi-Fi SSID, it implies that iPhone is still connected to previosly connected Wi-Fi.
At around the same point, iOS shows the system dialog "Unable to connect to Wifi". I checked for error in system logs while attempting connection, and found that the "wifid" process logs "__WiFiDeviceManagerForcedAssociationCallback: failed to association error 2" for com.apple.SystemConfiguration subsystem
I tried this couple of times, and got this error in console logs everytime connection attempt failed. App is able to connect on subsequent attempts.