CNCopyCurrentNetworkInfo() does NOT work on iOS13beta(17A5492t)

myApp has "Access WiFi Information Entitlement" as:

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

<true/>


CNCopyCurrentNetworkInfo() works on iOS12.3.1.

But it returns nil on iOS13 with same network environment as iOS12.3.1.

Answered by robbiet480 in 364495022

Check out WWDC 19 session 713, Advances in Networking, Part 2 (maybe 75% of the way through the presentation). CNCopyCurrentNetworkInfo is now only available to your app in three cases:


  • Apps with permission to access location
  • Your app is the currently enabled VPN app
  • Your app configured the WiFi network the device is currently using via NEHotspotConfiguration


If you don't meet at least one of these conditions CNCopyCurrentNetworkInfo will always return nil in iOS 13.


Having said all of that, I have ensured now that my app does have "Always Allow" location but I am still receiving nil from CNCopyCurrentNetworkInfo. Will report back if I figure it out.


EDIT: disregard that last statement, forgot I had commented out CNCopyCurrentNetworkInfo while attempting to implement the new WiFi framework 😁

Apparently, you also need Location permission in iOS 13

I met too, did you resolved?

Theres a new class called wifi which seems to return router information. Not sure what credentialis are needed, havent tried it.


https://developer.apple.com/documentation/wifi

I saw it, But I can't reference it on my project.In WIFI.framework has two classs. The WFConnectionStatus has 'SSID', 'BSSID', 'networkName' properties, but they don't has any overview.

Yes, it doesnt seem to work. The iOS simulator doesnt build, or link. I dont have iOS 13 on my device yet to test that. On a Mac build it didnt work though although it compile and link. Even with WIFI capabilities when i wrote this:



  connection.activate()
        connection.connectionStatusHandler = { newStatus in
                print(newStatus)
        }
        let deadlineTime = DispatchTime.now() + .seconds(4)
        DispatchQueue.main.asyncAfter(deadline: deadlineTime) {
            print(self.connection.lastConnectionStatus)
        }


The status was null and the handler was not called. Worth logging his I suppose.

Yeah, It's nil. And I can't understand WFConnectionStatus's networkName discussion, "Only available to the app that originally added the corresponding known network." Do you understand what's mean?

It means if your app didn't add the network to the phone, you can no longer see the name of the network the user is connected to. It’s one of the new privacy features in iOS 13, to prevent developers from using the network name to guess the user's location.

Accepted Answer

Check out WWDC 19 session 713, Advances in Networking, Part 2 (maybe 75% of the way through the presentation). CNCopyCurrentNetworkInfo is now only available to your app in three cases:


  • Apps with permission to access location
  • Your app is the currently enabled VPN app
  • Your app configured the WiFi network the device is currently using via NEHotspotConfiguration


If you don't meet at least one of these conditions CNCopyCurrentNetworkInfo will always return nil in iOS 13.


Having said all of that, I have ensured now that my app does have "Always Allow" location but I am still receiving nil from CNCopyCurrentNetworkInfo. Will report back if I figure it out.


EDIT: disregard that last statement, forgot I had commented out CNCopyCurrentNetworkInfo while attempting to implement the new WiFi framework 😁

I got dic from CNCopyCurrentNetworkInfo!

thanks 🙂

Hi, I'm still struggeling to get the networkInfo after successfully applying a NEHotspotConfiguration on iOS 13. As far as I understood I should be able to get infos about that network without location permissions.


/// retrieve the current SSID from a connected Wifi network
    private func retrieveCurrentSSID() -> String? {
        let interfaces = CNCopySupportedInterfaces() as? [String]
        let interface = interfaces?
            .compactMap { [weak self] in self?.retrieveInterfaceInfo(from: $0) }
            .first
        
        return interface
    }
    
/// Retrieve information about a specific network interface
    private func retrieveInterfaceInfo(from interface: String) -> String? {
        guard let interfaceInfo = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: AnyObject],
            let ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
            else {
                return nil
        }
        return ssid
    }


CNCopyCurrentNetworkInfo never returns anything. This code works fine on iOS 12.


It actually worked once when I switched from "kCNNetworkInfoKeySSID as String" to "SSID", but I guess that was just random. I did not change anything about the code but it stopped working again. Maybe beta 1 is flaky in that regard?


Does it work consistently for you?

I got the same problem in beta 2, did you resolve your issue?

I got the same problem in ios 13 beta 2, anybody resolve?

I think you should get support ios13 at iphone6

it's still happened on ios 13 beta 5

I'm still having the same problem with this in the newly released iOS 13 (build 17A577). Anyone else having a similar issue still?

same here 😟

+1

I am not getting SSID from CNCopyCurrentNetworkInfo in iOS 13.0


Project is satisfied following cases:


1. Apps with permission to access location

2. Your app configured the WiFi network the device is currently using via NEHotspotConfiguration


Added following in .entitlements file:


<key>com.apple.developer.networking.HotspotConfiguration</key>

<true/>


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

<true/>


I have followed many solutions but didn't work. Please suggest some solution to get SSID in iOS 13.


It would be great help! 🙂

I've had this problem occasionally with iOS 13.1.3. After rebooting the system, it returned to normal

I am having the same issue as you on the latest release of iOS13. I have "Always" location permissions and I still mostly get "nil" from calling

CNCopyCurrentNetworkInfo()


My testers have advised that it will sometimes return the correct value, but we have yet to be able to reliably recreate this situation.

CNCopyCurrentNetworkInfo

CNCopyCurrentNetworkInfo() does NOT work on iOS13beta(17A5492t)
 
 
Q