46 lines
1.2 KiB
Objective-C
46 lines
1.2 KiB
Objective-C
#import <CoreWLAN/CoreWLAN.h>
|
|
#import <CoreLocation/CoreLocation.h>
|
|
#import <Foundation/Foundation.h>
|
|
|
|
static CLLocationManager *locationManager = nil;
|
|
|
|
void RequestLocationPermission() {
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
if (locationManager == nil) {
|
|
locationManager = [[CLLocationManager alloc] init];
|
|
}
|
|
if (@available(macOS 10.15, *)) {
|
|
[locationManager requestWhenInUseAuthorization];
|
|
}
|
|
});
|
|
}
|
|
|
|
typedef struct {
|
|
char* ssid;
|
|
char* bssid;
|
|
} CWifiInfo;
|
|
|
|
CWifiInfo GetCurrentWifiInfo() {
|
|
CWifiInfo info;
|
|
info.ssid = NULL;
|
|
info.bssid = NULL;
|
|
|
|
@autoreleasepool {
|
|
CWWiFiClient *client = [CWWiFiClient sharedWiFiClient];
|
|
if (client != nil) {
|
|
CWInterface *interface = [client interface];
|
|
if (interface != nil) {
|
|
NSString *ssidStr = [interface ssid];
|
|
NSString *bssidStr = [interface bssid];
|
|
if (ssidStr != nil) {
|
|
info.ssid = strdup([ssidStr UTF8String]);
|
|
}
|
|
if (bssidStr != nil) {
|
|
info.bssid = strdup([bssidStr UTF8String]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return info;
|
|
}
|