CNCopySupportedInterfaces takes around 30-40s to return current connected ssid.

In our iOS application there are many places where we need to fetch current connected ssid and we are fetching it from CNCopySupportedInterfaces.We are observing an issue where CNCopySupportedInterfaces is taking 30 to 40 seconds to fetch ssid name which is therefore blocking the main thread and leading to make our application crash.
We did not find any issues calling this api CNCopySupportedInterfaces on main thread specified in any of the apple documents.

Please note we are experiencing this issue only in a particular network environment.

Code snippet :
  • (NSString *)getwifiName{

NSString *wifiStr = nil;
CFArrayRef arrayRef = CNCopySupportedInterfaces();
NSArray *interfaces = (_bridge NSArray *)arrayRef;
if (interfaces) {
for (NSString *interfaceName in interfaces) {
CFDictionaryRef dictRef = CNCopyCurrentNetworkInfo((CFStringRef)interfaceName);
if (dictRef != NULL) {
NSDictionary *networkInfo = (
bridge NSDictionary *)dictRef;
wifiStr = [NSString stringWithFormat:@"%@",[networkInfo objectForKey:@"SSID"]];
CFRelease(dictRef);
}
}
CFRelease(arrayRef);
}
if(wifiStr == nil)
{
wifiStr = [NSString stringWithFormat:NSLocalizedString(@"Mobile
DeviceWIFINotEnable",nil)];
}
Code Block
NSLog(@"Connected WifiStr - %@",wifiStr);

return wifiStr;
}

To start, I recommend that you file a bug about this. CNCopySupportedInterfaces.We should never take that long.

As part of this:
  • Install the Wi-Fi for iOS profile, available on our Bug Reporting \> Profiles and Logs page.

  • Likewise the Network Diagnostics for iOS profile.

  • Attach a sysdiagnose log from the affected device, one taken shortly after you triggered the problem. Again, instructions are on the above-mentioned page.

Please post your bug number, just for the record.

Please note we are experiencing this issue only in a particular
network environment.

All devices in that environment? What spread of iOS releases have your tested?

ps When posting code snippets, format them as a code block using the <> button.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Yes, all devices in that environment is causing the issue.Tested on iOS 13.x releases.

Thanks,
RS

Yes, all devices in that environment is causing the issue.

Interesting.

Tested on iOS 13.x releases.

Does that mean that iOS 14 doesn’t show this problem? Or that you didn’t test with iOS 14?

Oh, and you bug number?

Share and Enjoy

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

Do you know how to get wifi ssid for Apple TV as I am not finding API available to get wifi ssid? CNCopySuppportedInterfaces is unavailable for tvOS and is there any alternative for tvOS?

CNCopySuppportedInterfaces is unavailable for tvOS and is there any alternative for tvOS?

Two things:

  • CNCopySuppportedInterfaces has been deprecated in favour of +[NEHotspotNetwork fetchCurrentWithCompletionHandler:].

  • That API is also not available on tvOS.

AFAIK there’s no way to get this info on tvOS. You should feel free to file an enhancement request for that. Please post your bug number, just for the record.

Just for my own curiosity, why do you need this on an Apple TV?

Share and Enjoy

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

CNCopySupportedInterfaces takes around 30-40s to return current connected ssid.
 
 
Q