Capabilities for Location Services

Can anyone explain why I need to provide location service capabilities to get BSSID info for the Wi-Fi network device?

Here some notes from CWNetwork header

Code Block language
/*!
* @property
*
* @abstract
* Returns the basic service set identifier (BSSID) for the Wi-Fi network device, returned as UTF-8 string.
*
* @discussion
* Returns a UTF-8 string using hexadecimal characters formatted as XX:XX:XX:XX:XX:XX.
*
* @note
* BSSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
*
* @seealso
* CLLocationManager
*/
@property(readonly, nullable) NSString *bssid NS_AVAILABLE_MAC(10_6);


Accepted Reply

Can anyone explain why I need to provide location service capabilities
to get BSSID info for the Wi-Fi network device?

Because folks abuse the BSSID to track the user’s location )-:

Share and Enjoy

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

Replies

Can anyone explain why I need to provide location service capabilities
to get BSSID info for the Wi-Fi network device?

Because folks abuse the BSSID to track the user’s location )-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thanks for answer.
BTW: can I set location capabilities to privileges helpers?

can I set location capabilities to privileges helpers?

A privileged helper tool installed via SMJobBless?

Share and Enjoy

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

is there any sample swift code showing how to do this?

Also, is anyone going to update bssid() in CoreWLAN to reflect this requirement? I mean, it might be nice so you don't beat your head against a wall trying to work around a bug that isn't.

is there any sample swift code showing how to do this?

Do what, specifically? This thread has covered two separate issues:

  • Using the location privilege to get the BSSID

  • Granting location privileges do a daemon

Also, is anyone going to update bssid() in CoreWLAN to reflect this requirement?

I’d appreciate you filing a bug requesting an update to the doc comment. Please post your bug number, just for the record.

Share and Enjoy

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

documentation radar: FB10364979

On how to do this, I meant with location services. So I managed to muddle through some of it (y'all really need to look at how MS does their dev docs, the sample code for things here is really skimpy)

What I have so far:

in my "main" file (not the contentview file):

class locationDelegate: NSObject, CLLocationManagerDelegate {
	func theLocationAuthStatus(_manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
		print("changed auth status: \(status.rawValue)")
		switch status.rawValue {
			case 0:
				print("Not Determined")
			case 1:
				print("Restricted")
			case 2:
				print("Denied")
			case 3:
				print("Authorized Always")
			case 4:
				print("Authorized when in use")
			default:
				print("None of the above")
		}
	}
}

In my ContentView file:

@State var myLocationManager = CLLocationManager()

<lots of swiftui UI stuff>

.onAppear {
		    let myDelegate = locationDelegate()
		    myLocationManager.requestWhenInUseAuthorization()
		    myLocationManager.startUpdatingLocation()
		    myLocationManager.delegate = myDelegate
		    myLocationManager.delegate
		    print(myLocationManager.authorizationStatus.rawValue)
		    let myLocationManagerAuthStatus = myLocationManager.authorizationStatus.rawValue
		    if myLocationManagerAuthStatus == 3 || myLocationManagerAuthStatus == 4 {
				//get BSSID
			    print("we're authorized")
			    currentWAPMAC = getBSSID()
		    }

		    //set up the SSID value
		    currentSSID = getSSID()
		    //get the Wifi Channel. if it's a zero,
		    //channel is actually nil
		    currentChannel = getCWChannelNumber()
		    //set up the RSSI
		    signalStrength = getRSSI()
		    //BRING THA NOIZE
		    signalNoise = getNoise()
		    //get the SNR as a formatted string via NumberFormatter
		    signalToNoise = getSNR(theSig: signalStrength, theNoise: signalNoise)
		    //get transmit rate
		    dataRate = getTransmitRate()
		    //get current time
		    self.theCurrentTime = getCurrentTime()
		    //stop the timer
		    self.stopTimer()
	    }

create the interface object:

func getWifiInterface() -> CWInterface {
	let theWirelessClient = CWWiFiClient.shared()
	let theWirelessInterface = theWirelessClient.interface()
	return theWirelessInterface!
}

//moved this from contentview to here. Probably a better place for all this
var theWifiInterface: CWInterface = getWifiInterface()

the getBSSID() function:

func getBSSID() -> String {
	if let theBSSID = theWifiInterface.bssid() {
		return theBSSID
	} else {
		let theBSSID = "no BSSID"
		return theBSSID
	}
}

So on run, 

print(myLocationManager.authorizationStatus.rawValue) prints a 3, so cool, we're auth'd and the dialog has been appearing nice and consistent-like

and the 

 if myLocationManagerAuthStatus == 3 || myLocationManagerAuthStatus == 4 {
		//get BSSID
	    print("we're authorized")
	    currentWAPMAC = getBSSID()
}

prints "we're authorized" as expected, but no BSSID returned. Everything else, the SSID, the channel, the Signal/Noise strengths, the Data Rate, that I get fine, but I can't get the BSSID. I know I'm missing something simple, but i'm completely puzzled as to what.

Thanks!