macOS get SSID changes?

Apple Recommended

  • I guess I get to learn about requesting location services access :D Feedback submitted FB12569894

    Thank you!

  • I know it's a couple months later but thank you for this! The official docs still haven't been updated and this bug was driving me nuts. I appreciate your help.

Add a Comment

Replies

I've had a little personal utility

Is this a command-line tool? Or an app?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Add a Comment

Same issue here, my app uses CWWiFiClient.shared() to retrieve SSID name and it currently returns nil on macOS Sonoma beta 2

Putting this in a command line macOS app and a playground yield different results. The app prints unavailable, the playground prints the SSID name.

import Foundation
import CoreWLAN

let client = CWWiFiClient.shared()
let ssid_name = client.interface()?.ssid() ?? "unavailable"

print(ssid_name)

Same issue still here in Sonoma beta3.

  • I guess I get to learn about requesting location services access :D Feedback submitted FB12569894

    Thank you!

  • I know it's a couple months later but thank you for this! The official docs still haven't been updated and this bug was driving me nuts. I appreciate your help.

Add a Comment

Is this problem solved? After I tried to get the location permission, it also return nil.

getting null even after adding the "com.apple.security.personal-information.location" entitlement, is there anything else to add in the entitlements. I have the below <key>com.apple.security.personal-information.location</key> <true/> <key>com.apple.security.network.client</key> <true/>

but still no luck.

Yes, I got it working with Location Services. I added a file for a LocationController and then in my main view added an onAppear(perform: { if LocationServices.shared.locationManager.authorizationStatus == .authorizedAlways { LocationServices.shared.userLocationDelegate = self } else { LocationServices.shared.locationManager.requestAlwaysAuthorization() } }) My code is up at https://github.com/ehemmete/NetworkView

  • Also found that, with the release Sonoma, CWWifiClient.shared().interface() returns nil unless Outgoing Connections(Client) is checked in network App Sandbox settings

Add a Comment

Im still so confused on how to simply get a network SSID for a background application running DotNet Core on macOS now. Before, I could just call CWifiClient.networkInterfaces, now the value returns null. What steps do I need to take to enable this application which is signed with its own embedded provisioning profile? Do I detect if authorization is required, then request the prompt?

#if _UNIX

using System; using CoreWlan; using CoreLocation; //??? using ThreadNetwork;

namespace Amazon.PersistUserService.Controllers.NetworkController.NetworkChangeManager;

public class MacNetworkChangeManager: INetworkChangeManager { private readonly CoreWlan.CWWiFiClient networkClient; private CLLocationManager locationManager; //???

public MacNetworkChangeManager()
{
    networkClient = CWWiFiClient.SharedWiFiClient;
}

public string? GetConnectedSsid()
{
    //What do I add here to request authorization?
    
    foreach (var @interface in networkClient.Interfaces) // you can have multiple wifi devices connected at once
    {
        return @interface.Ssid;
    }
    return null;
}

} #endif

how to simply get a network SSID for a background application

What do you mean by “background application”? How is your program started?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hello @eskimo , my program is written in DotNet 6, and I use Xamarin.Mac SDK: https://learn.microsoft.com/en-us/dotnet/api/?view=xamarin-mac-sdk-14 Before as in my code, i was able to get the connected SSID without any issue. Now it returns null. Do I need to add an entitlement and prompt the user using Core Location? I'm not sure how to use it with Xamarin.Mac SDK in a dotnet application from the instructions here: https://developer.apple.com/documentation/corelocation/configuring_your_app_to_use_location_services

  • The application is started by launchd, it is a LaunchAgent.

Add a Comment

A launchd agent should be able to get this info. Is the agent associated with a standard GUI app? For example, you might be installing the agent from that app using SMAppService? Or is the agent a standalone thing?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • thanks for the response, @eskimo . The agent is associated with a standard GUI app, they share the same keychain group, for example. So the steps would be to enable resource access by adding com.apple.security.personal-information.location to the entitlements file associated with the application, then following the CLLocation mechanism so that the prompt is accepted before accessing the resource?

Add a Comment

How do I use NSLocationAlwaysAndWhenInUseUsageDescription on macOS so that users know why I am requesting location?

Sorry, one more issue @eskimo : https://learn.microsoft.com/en-us/dotnet/api/corelocation.cllocationmanager?view=xamarin-ios-sdk-12 Corelocation API is only available for xamarin.ios is there an equivalent for macOS to use? I used @ehemmete approach to get my GUI to enable location information, but the launch agent is not able to fetch location information

The agent is associated with a standard GUI app

Cool. How do you install the the agent? SMAppService? Or something else?

CoreLocation API is only available for xamarin.ios is there an equivalent for macOS to use?

Core Location is supported on all our platforms. See the pills at the top of its main doc page. If that’s not reflected in your third-party tooling, I recommend that you raise this via its support channel.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"