Wi-Fi detection enabled (regardless of whether it is connected)

For a GPS tracking application, location signals with WIFI enabled result in truly inaccurate or broken data.

I used Reachability queries to determine if there was Wi-Fi before starting tracking. The problem is that if during the execution of this request Wi-Fi is turned on but not connected to the network, it shows that the Internet is not available via Wi-Fi, but this does not indicate whether the option is disabled in the settings application. This means that if the user starts working and the connection starts in the middle, they will receive a location signal from Wi-Fi instead of a GPS network or a cellular network. Therefore, the accuracy of these data points can be> 10 meters, so I want to skip this point. The problem is that in wifi they will have a big empty period when their signal was not recorded.

So how can I check if wifi is turned on but disconnected?

I read all the other reachability discussions that I could find, but this seems to be the only gap in which many answers incorrectly indicate that reachability solves this out of the box.

... and I'm not going to demand wifi - just to warn them that it is turned on, so at some point in their training their location data may be lost (due to inaccuracy).

+7
source share
2 answers

It's been quite a while since you asked, but I just stumbled upon this.

There doesn't seem to be any way to do this if you want to obey Apple rules. sysctl and ioctl will not work, because there are no flags that show you that WiFi is on. For example, the flags for “UP” and “RUNNING” will be the same if WiFi is disabled or WiFi is enabled but not connected.

Apple’s proprietary Wi-Fi infrastructure uses mach to interact directly with the kernel, and I doubt that Apple will allow such code in the AppStore.

+2
source

It is possible, but the solution is obscure and ugly. Short answer: if you see TWO interfaces with the name "awdl0", then WiFi is turned on, only one is turned off.

See Best way to detect WiFi on / off in iOS? for a more complete description and sample code.

0
source

All Articles