Sunday, 1 November 2020

iOS: Getting current WiFi SSID is always nil on Testflight

Below is the code I use to get my current WiFi SSID and display it in my app.

I have location permissions set to always, as well as the required Privacy info.plist values. I also have the Access WiFi Information capability added to my project. When I build the app from Xcode to my iPhone (not simulator), it works fine, I can see my WiFi SSID. However, when I distribute the app through Testflight it no longer works, it is returning nothing.

import SystemConfiguration.CaptiveNetwork

private func getWiFiSsid() -> String? {
        var ssid: String?
        if let interfaces = CNCopySupportedInterfaces() as NSArray? {
            for interface in interfaces {
                if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
                    ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
                    break
                }
            }
        }
        return ssid
    }

Below is a screenshot of the entitlements that I unpackages from the ipa file, showing that I do have the Access WiFi Information set: WiFi entitlement



from iOS: Getting current WiFi SSID is always nil on Testflight

No comments:

Post a Comment