Detect a specific System Alert/Popup

Hi, I am working on a app that tries to connect the iPhone to the Wifi network provided the SSID and password.

I have used NEHotspotConfiguration and majiority of the times, it works as expected -> the Wifi connection is established.

However, sometimes the system shows the following popup (although the SSID and Passwords are valid):

I need to detect programmatically (in swift) if the system has presented this specific popup. How can I achieve this?

Gone through so many Q/A but failed to get any solutions... Anyone?

Thank you.

Replies

There is no API to check if this system alert is available directly from the Network Extension framework. If you are not able to detect that an error took place on the callback of apply(_:completionHandler:) then one technique you could try is to wait for 3-5 seconds after calling apply, for your device to receive an IP, and then try to communicate with the device through a HTTP request or TCP connection (or however you planned to communicate with the device). If the request / connection immediately fails, which is should if you were not able to associate with this network, then tear down the association and retry as your business logic sees fit.