Checking Wi-Fi Status for Location Accuracy in iOS App

I am working on a duress app and would like to improve location accuracy by encouraging users to enable Wi-Fi. In Apple Maps, I noticed that when Wi-Fi is off, a dialog prompts users to turn on Wi-Fi to enhance location accuracy. I am looking to implement similar functionality in my app. Specifically, I would like to check whether Wi-Fi is enabled on the user's device (even if it is not connected to a network). Despite exploring several methods, I have been unable to determine a reliable way to check the Wi-Fi status. Can you guide me on whether it is possible to access this functionality in iOS, and if so, how I can implement it within my app?

Answered by DTS Engineer in 824615022

Speaking from a networking perspective, iOS has no API that answers the question “Is Wi-Fi on or off?” If you try to infer this state from other APIs, you’ll inevitably run into weird problems (something you seem to have discovered already).

For a summary of what Wi-Fi APIs are available are available on iOS, see TN3111 iOS Wi-Fi API overview.

There may be more answers to this in the Core Location space, but that’s not my area of expertise and so I’ll leave others to comment on that.

Share and Enjoy

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

Accepted Answer

Speaking from a networking perspective, iOS has no API that answers the question “Is Wi-Fi on or off?” If you try to infer this state from other APIs, you’ll inevitably run into weird problems (something you seem to have discovered already).

For a summary of what Wi-Fi APIs are available are available on iOS, see TN3111 iOS Wi-Fi API overview.

There may be more answers to this in the Core Location space, but that’s not my area of expertise and so I’ll leave others to comment on that.

Share and Enjoy

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

From a CoreLocation perspective, there still isn't a direct way to check if WiFi is on or not. There could be ways for you to guess whether the location is being obtained via WiFi or not, but that won't be reliable enough to annoy your users with unnecessary prompts.

Speaking of which, why do you believe you need to prompt the users in addition to the system reminding of the accuracy drop? They already got prompted and would have made their decision regarding WiFi. Do you plan to keep prompting them until they delete the app? Otherwise, you can consider the question has been asked and answered.

Now on the technical side, I don't know which CoreLocation APIs you are using, but if you use the Significant Location Change API you can check the horizontalAccuracy of the returns CLLocations. If they are at best 60 meters, and generally in the 100 meter accuracy range, that could mean the location source is WiFi. Of course, this will in no way dismiss other possibilities, like WiFi being on, but being in an area with very poor coverage (therefore much less accurate locations), or another app on the device requesting GPS locations, and then the system sharing the more accurate location with your app (free upgrade), and changing the accuracy of the locations you get.


Argun Tekant /  DTS Engineer / Core Technologies

Checking Wi-Fi Status for Location Accuracy in iOS App
 
 
Q