iOS 13 fetch Wifi SSID is broken even though location access is given

Since we know , As per latest update to Apple's privacy policy Starting with iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information . As per apple's guidelines the app must meet at least one of the criteria mentioned below to fetch the network information.

  1. The app uses Core Location, and has the user’s authorization to use location information.
  2. The app uses the NEHotspotConfigurationAPI to configure the current Wi-Fi network.
  3. The app has active VPN configurations installed.

In our app we used core location access for fetching wi-fi ssid. It works most of the times if the location access is given by user but in some devices we are seeing an issue that even though location access is given by user, we are still not able to fetch wifi-ssid and once we restart the phone everything starts working then. Seems like a possible bug with iOS 13. Has anyone else faced same issue ?

In order to verify that there is no problem with my code, I checked in other apps like Share it, SweetSpots which also uses Core Location to fetch Wi-fi ssid, they were also not able to fetch wifi ssid until phone is restarted. Something is fishy with iOS 13 which gets cleaned when phone is rebooted.

Replies

Looking at the header information on CNCopyCurrentNetworkInfo, it also looks like if an application is linked against the iOS 12 SDK and later an application must have the "com.apple.developer.networking.wifi-info" entitlement configured.


@function CNCopyCurrentNetworkInfo
 @discussion Returns the network information for the specified interface when the requesting application meets one of following 3 requirements -.
  1. application is using CoreLocation API and has user's authorization to access location.
  2. application has used NEHotspotConfiguration API to configure the current Wi-Fi network.
  3. application has active VPN configurations installed.

  - An application that is linked against iOS 12.0 SDK and above must have the "com.apple.developer.networking.wifi-info" entitlement.
  - An application will receive a pseudo network information if it is linked against an SDK before iOS 13.0, and if it fails to meet any of the
    above 3 requirements.
  - An application will receive NULL if it is linked against iOS 13.0 SDK or above, and if it fails to meet any of the above 3 requirements..


To test this out I setup the following project using these steps:

1) Added the CoreLocation permissions to the Info.plist.


<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Gather location updates to get SSID information</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Gather location updates to get SSID information</string>


2) Added the Access WiFi Information capbilitiy.

<key>com.apple.developer.networking.wifi-info</key>
<true/>


3) Accessed the SSID information using this code. (Courtesy of eskimo)

import SystemConfiguration.CaptiveNetwork

func getSSIDs() -> [String] {
    guard let interfaceNames = CNCopySupportedInterfaces() as? [String] else {
        return []
    }
    
    return interfaceNames.compactMap { name in
        guard let info = CNCopyCurrentNetworkInfo(name as CFString) as? [String: AnyObject] else {
            return nil
        }
        guard let ssid = info[kCNNetworkInfoKeySSID as String] as? String else {
            return nil
        }
        
        return ssid
    }
}


4) Tested this using the following scenarios.

  • Connected to WiFi directly.
  • Connected to WiFi, turn on Cellular, and re-connected to WiFi. Cellular correctly lost the WiFi information and picked it back up when it was turned back on.
  • Connected to WiFi. Tunred off the device. Relaunched the application and seen the WiFi pick back up.


Possibly the difference is the Wifi-info entitlement?

Hope this helps.

once we restart the phone everything starts working then.

See my response on this thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Dear support,

We are also facing the same issue, and also resolving it with a phone reboot.

It seems not very acceptable by our customers !

Does Apple want to fix it ?

Thanks in advance.

I am wondering if iOS 13.2 addresses this issue?