Cannot retrieve SSID from CNCopyCurrentNetworkInfo even if location permission is kCLAuthorizationStatusAuthorizedWhenInUse

My App try to retrieve the ssid of the device to know if users are in the range of a store with hotspot. it's like geolocalisation but we also use it to optimize the experience of user when data is not available in indoor store.


After iOS 12, we add in entitlements "Access WiFi Information", everything work correctly.


According to iOS13 update, we have to respect at least one of criteria below to retrieve ssid

* app must have permission to access location

* enabled VPN app

* NEHotspotCOnfiguration


We decide to use access location. When the application launch we request authorization for localisation, then, we try to retrieve the ssid, but CNCopyCurrentNetworkInfo always return an empty dictionnary even if CLAuthorisationStatus is equal to kCLAuthorizationStatusAuthorizedWhenInUse (user accept it)


So, here is my code for detecting the current SSID:

NSString *wifiName = [NSString stringWithFormat:@""];
        CFArrayRef wifiInterfaces = CNCopySupportedInterfaces();
       
        NSArray *interfaces = (__bridge NSArray *)wifiInterfaces;
        for (NSString *interfaceName in interfaces) {
            CFDictionaryRef dictRef = CNCopyCurrentNetworkInfo((__bridge CFStringRef)(interfaceName));
            if (dictRef) {
                NSDictionary *networkInfo = (__bridge NSDictionary *)dictRef;
               
                wifiName = [NSString stringWithFormat:@"%@",[networkInfo objectForKey:(__bridge NSString *)kCNNetworkInfoKeySSID]];
            }
        }
return wifiName;

The code will be called only when CLAuthorisationStatus is authorize

Here is a example:

if (![CLLocationManager locationServicesEnabled]) {
     _locationManager.delegate = self;
     [_locationManager requestAlwaysAuthorization];
} else {
     CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
     if ((status!==kCLAuthorizationStatusRestricted) || (status!==kCLAuthorizationStatusDenied)) {
          // retrieve the ssid from the previous function              
     }
}

Accepted Reply

I am having this same issue. Location While in Use/Always Permission allowed and Access WiFi Information capability, but I am not getting WiFi info back. This was working with the iOS 13 betas I tested, but it did not work with the final release.


Based on my testing, this seems to be a bug that is fixed in the latest 13.1 beta. Hopefully the 13.1 release today resolves this issue.


Edit: I just tested on the offical 13.1 release, and this issue seems to be fixed. Hopefully it is resolved for you as well.

Replies

I am having this same issue. Location While in Use/Always Permission allowed and Access WiFi Information capability, but I am not getting WiFi info back. This was working with the iOS 13 betas I tested, but it did not work with the final release.


Based on my testing, this seems to be a bug that is fixed in the latest 13.1 beta. Hopefully the 13.1 release today resolves this issue.


Edit: I just tested on the offical 13.1 release, and this issue seems to be fixed. Hopefully it is resolved for you as well.

iOS 13.1.3 seems return nil even the location privileges had been approved.

Btw after the device rebooting, it works. Very unstable.

Please re-test on the latest 13.2 beta. See this thread for some background on this.

Share and Enjoy

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

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