Search code examples
ioswifireachabilityairplane-mode

Reachability: Airplane Mode with Wifi ON


I'm currently using Reachability to detect an available connection. This works great when there's nothing or when there's a good connection. But what if my user is on a plane with its own wifi node that is not connected to the internet at large? My user will be in airplane mode with wifi on and Reachability gets confused -- it tells me she's connected but she isn't connected enough for my HTTP calls.

Reachability detects the wifi but is not granular or subtle enough to determine if the wifi is really providing access to the internet. This could also happen at a cafe or office when trying to connect to wifi but not having the correct credentials to be authorized.

Is it possible to detect if a wifi node is asking for credentials? Do I need to make an HTTP call to check for true connectivity? Is there a more clever way to solve this problem?


Solution

  • As far as I know, you will have to do some work to do this. FYI, when the interfaces turn on for WiFi and the cell modem, there is the whole handshaking thing when the interface comes back online. There are differences in whether the interface is open and on and whether it has an IP address and whether it can reach an internet address or not. I know this matters more when we turn airplane mode off and connectivity resumes, but there is the whole "starting up and acquiring an IP address" thing that sometimes we forget about.

    I'd check the reachability flags for each interface and then see if you can hit an address and get data back over that interface.