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.

Accepted Reply

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.
  • We can able to obtain the ssid as mentioned above in iOS. But in Mac Catalyst, We cant able to do so. Access Wifi Information Entitlement is not getting added in capability for mac os.. Is there any other way to make it work.

    Error in xcode console - NEHotspotNetwork nehelper sent invalid result code [1] for Wi-Fi information request

Add a Comment

Replies

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

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.
  • We can able to obtain the ssid as mentioned above in iOS. But in Mac Catalyst, We cant able to do so. Access Wifi Information Entitlement is not getting added in capability for mac os.. Is there any other way to make it work.

    Error in xcode console - NEHotspotNetwork nehelper sent invalid result code [1] for Wi-Fi information request

Add a Comment
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
  • I tried to get SSID and BSSID from iphone running with IOS 15.1. it always return null, even my app has authorization to access precise location.

    According to the document, from IOS 14. an APP can get SSID and BSSID of the current Wi-Fi network when it meets one of following 4 requirements: application is using CoreLocation API and has user's authorization to access precise location. application has used NEHotspotConfiguration API to configure the current Wi-Fi network. application has active VPN configurations installed. application has active NEDNSSettingsManager configuration installed. In my case, I have the authorization to access precise location, but still I can't get SSID and BSSID. Please advise.

Add a Comment
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...
  • Does it work?

  • @hegar, the example in the link I provided above, based on @tclark's outlined answer is still he recommended path. If you find that this does not work for you then please create a new post with a description of how your have your project setup and the code you are using to obtain the associated SSID.

Add a Comment