Apple changed some things regarding WiFi with iOS 13. If you want to use CNCopyCurrentNetworkInfo your app needs to have one of the following
Source: WWDC 19 session 713
I am configuring a network using NEHotspotConfiguration but I can not get the current SSID anymore after doing so.
The following code worked fine with iOS 12:
/// 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 }
With iOS 13 CNCopyCurrentNetworkInfo
always returns nil.
My app has the Access WiFi Information Capability set.
Thanks for your help!
The class you'll need to use is called NEHotspotConfiguration . To use it, you need to enable the Hotspot capability in your App Capabilities (Adding Capabilities). Quick working example : NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc] initWithSSID:@“SSID-Name”]; configuration.
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 have a similar issue in my app. I have submitted a feedback form to Apple and got a response stating:
Potential fix identified - For a future OS update
So hopefully, this will be resolved before the final release (not in iOS 13 Beta 4 though).
For a workaround, you can set joinOnce = false
in your NEHotspotConfiguration
. In my app, it allowed me to access CNCopySupportedInterfaces
, but required me to remove configuration every time my app was closed.
Hope it helps!
Edit:
It seems that in iOS 13 beta 5 issue no longer persists. In my application, I can access CNCopyCurrentNetworkInfo
again (thus confirming the Wi-Fi has been connected), no matter if NEHotspotConfiguration.joinOnce
flag is set to true
or false
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With