How to know if ios device is connected to open or public wifi

I am working on an app where I need to detect if the ios device is connected to open wifi or not. Is there any API which can help detect the same?

You’ll need to be more specific about what you mean by “open or public wifi”.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi,

What I meant was how do we detect if we are connected to wifi which doesn't need any password to connect, like we have at malls, cafes etc

[a Wi-Fi which needs a] password to connect, like we have at malls, cafes etc

In Apple parlance this is known as a captive network [1]. In most cases your app doesn’t have to worry about this because the OS detects the network and the Wi-Fi only becomes the default route once the OS has successfully authenticated with the network.

However, there are some captive networks that go out of their way to fool the OS into thinking they are not captive. Detecting those is tricky because:

  • The fact that the network has becomes the default route means that the network has successfully fooled the OS, so no API will help you out.

  • The tricks they use to fool the OS may well fool your checks.

Why do you need to detect this? Because my general advice is that you not worry about this and instead use TLS (so HTTPS) everywhere. That prevents the network from intercepting your connections, so the captive network just looks like any other broken network.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] It’s sometimes also called a hotspot, but that’s confusing because folks often use that term to mean any Wi-Fi network.

Hi,

I am working on an app where I need to present user with some diagnostic report and detecting whether wifi is open wifi or not is one of the items in the report. This is where my question is coming from.

So, you want to distinguish between two different situations:

  • In the first, the device has joined a normal Wi-Fi network and your app is using that network.

  • In the second, the device has joined a captive network and successfully negotiated [1] it. Your app is then using that network.

Is that right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Or the user has done that negotiation, in the case where the captive network has successfully fooled iOS into thinking its not captive.

Hi Eskimo,

Yes, that's right.

Yes, that's right.

OK. I don’t see any way to distinguish those cases.

One thing that can help is the ability to determine the network security type — see this post — but that doesn’t let you distinguish between captive networks and completely open networks.

I think it’d be reasonable for us to enhance NEHotspotNetwork to include info about whether the system is treating it as a captive network. If you’d like to see such a property added in the future, I encourage you to file an enhancement request describing your requirements.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to know if ios device is connected to open or public wifi
 
 
Q