Apple changed some things regarding WiFi with iOS 13. If you want to use CNCopyCurrentNetworkInfo your app needs to have one of the following
As I said on the Apple Developer Forums use of CNCopyCurrentNetworkInfo
is now limited.
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:
If you don't meet at least one of these conditions CNCopyCurrentNetworkInfo
will always return nil
in iOS 13.
UPDATE: As of iOS 13 Developer Beta 6, Apple has finally updated the documentation to note the changes.
I've spent hours trying to figure out a way to let CNCopyCurrentNetworkInfo
works on iOS 13 with no results, no matter location permissions status or the fact that my app configured the current Wi-Fi network the device is currently using via NEHotspotConfiguration
. It just does not work.
I finally came out with the reliable solution to get the SSID through getConfiguredSSIDsWithCompletionHandler:
method of NEHotspotConfigurationManager
.
Here's a simple example:
static func retrieveCurrentSSID( callback: @escaping ( String? ) -> Void ){
NEHotspotConfigurationManager.shared.getConfiguredSSIDs { ( networkSSIDs ) in
callback( networkSSIDs.first )
}
}
Must verify that
<key>com.apple.developer.networking.wifi-info</key>
<true/>
is added to Entitlements-Release.plist, mostly its just added to Entitlements-Debug.plist only
I believe that you match one of the following condition which is suggested by Apple:
1 :Apps with permission to access location
2 :Your app is the currently enabled VPN app
3 :Your app configured the WiFi network the device is currently using via NEHotspotConfiguration
In my case even i have location services enable when was facing the issue.
After some workaround here are i found the two solution which you can try:
1: Reboot the device. This works for me!!.
2: Update the OS if available.
I am not sure it helps you but in few cases it should work, few people suggest reboot 2-3 times work for them.
Another good news from Apple that they fix for this issue on iOS 13.3 beta version