Getting the Wi-Fi's SSID on macOS

I want to extend an existing macOS app distributed through the Mac App Store with the capability to track the Wi-Fi's noise and signal strength along with the SSID it is connected to over time.

Using CWWiFiClient.shared().interface(), I can get noiseMeasurement() and rssiValue() fine, but ssid() always returns nil.

I am assuming this is a privacy issue (?).

Are there specific entitlements I can request or ways to prompt the user to grant the app privilege to access the SSID values?

Answered by Todd2 in 794014022

I figured it out. I just needed to request permission for Core Location services.

Added this code to one of my objects:

locationManager = CLLocationManager()
locationManager?.delegate = myLocationDelegate
locationManager?.requestWhenInUseAuthorization()

For my app sandbox, I also enabled

  • Outgoing Connections (Client)
  • Location

(I'm not certain the second one is needed)

I now get the SSID and BSSID.

Also, the app now shows up in System Setting's Location Services, where I guess the user can turn it on or off.

I figured it out. I just needed to request permission for Core Location services.

Added this code to one of my objects:

locationManager = CLLocationManager()
locationManager?.delegate = myLocationDelegate
locationManager?.requestWhenInUseAuthorization()

For my app sandbox, I also enabled

  • Outgoing Connections (Client)
  • Location

(I'm not certain the second one is needed)

I now get the SSID and BSSID.

Also, the app now shows up in System Setting's Location Services, where I guess the user can turn it on or off.

Getting the Wi-Fi's SSID on macOS
 
 
Q