Get the name of the Wi-Fi network to which the device is currently associated

Hello,

My app just need to get the name of the Wi-Fi network to which the device is currently associated.

In the following QA1942 they talk about  CNCopyCurrentNetworkInfo which is now deprecated.

So what can I use with iOS 14 to just get the name of the Wi-Fi network to which the device is currently associated ?

Regards,
Fred.

Answered by in 672831022
Starting with iOS 14, the SSID and BSSID of the currently connected Wi-Fi network can be obtained using the fetchCurrent(completionHandler:) method of the NEHotspotNetwork class. Note that the use of fetchCurrent(completionHandler:) does not require the NEHotspotHelper entitlement.

This method returns SSID and BSSID of the current Wi-Fi network when the requesting application meets one of following 4 requirements:
  1. application is using CoreLocation API and has user's authorization to access precise location.

  2. application has used NEHotspotConfiguration API to configure the current Wi-Fi network.

  3. application has active VPN configurations installed.

  4. application has active NEDNSSettingsManager configuration installed.

An application will receive nil if it fails to meet any of the above 4 requirements.
An application will receive nil if does not have the "com.apple.developer.networking.wifi-info" capability.
There are more and more limitations to such information access (because it lets you get information on user location, hence privacy issue).

This may provide some hint to a solution:
https://stackoverflow.com/questions/63130232/cncopycurrentnetworkinfo-not-working-with-ios-14
or this older (5 years !) thread:
https://developer.apple.com/forums/thread/11807

or this (but that's more general conditions than practical solution)
https ://blog.appnation. co/how-to-access-wifi-ssid-on-ios-13-using-swift-40c4bba3c81d

Accepted Answer
Starting with iOS 14, the SSID and BSSID of the currently connected Wi-Fi network can be obtained using the fetchCurrent(completionHandler:) method of the NEHotspotNetwork class. Note that the use of fetchCurrent(completionHandler:) does not require the NEHotspotHelper entitlement.

This method returns SSID and BSSID of the current Wi-Fi network when the requesting application meets one of following 4 requirements:
  1. application is using CoreLocation API and has user's authorization to access precise location.

  2. application has used NEHotspotConfiguration API to configure the current Wi-Fi network.

  3. application has active VPN configurations installed.

  4. application has active NEDNSSettingsManager configuration installed.

An application will receive nil if it fails to meet any of the above 4 requirements.
An application will receive nil if does not have the "com.apple.developer.networking.wifi-info" capability.
Accepted Answer
There is also an example of both fetchCurrent and CNCopyCurrentNetworkInfo out in Configuring a Wi-Fi Accessory to Join the User’s Network.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Thanks for your answers. I better understand the operation.

But it's a lot of dev and permissions to request to just get the SSID of the current wifi...
Get the name of the Wi-Fi network to which the device is currently associated
 
 
Q