Adjust current SSID to also support Catalyst

This commit is contained in:
Davide De Rosa 2022-04-05 21:24:06 +02:00
parent 521c1fd79d
commit 46918a767a
1 changed files with 9 additions and 7 deletions

View File

@ -109,15 +109,15 @@ public class InterfaceObserver: NSObject {
/** /**
Returns the current Wi-Fi SSID if any. Returns the current Wi-Fi SSID if any.
- Returns: The current Wi-Fi SSID if any. - Parameter completionHandler: Receives the current Wi-Fi SSID if any.
**/ **/
public static func fetchCurrentSSID(completionHandler: @escaping (String?) -> Void) { public static func fetchCurrentSSID(completionHandler: @escaping (String?) -> Void) {
#if os(iOS) #if os(iOS)
// if #available(iOS 14.0, *) { if #available(iOS 14, macCatalyst 14, *) {
// NEHotspotNetwork.fetchCurrent { NEHotspotNetwork.fetchCurrent {
// completionHandler($0?.ssid) completionHandler($0?.ssid)
// } }
// } else { } else if #available(macCatalyst 14, *) {
guard let interfaceNames = CNCopySupportedInterfaces() as? [CFString] else { guard let interfaceNames = CNCopySupportedInterfaces() as? [CFString] else {
completionHandler(nil) completionHandler(nil)
return return
@ -132,7 +132,9 @@ public class InterfaceObserver: NSObject {
} }
} }
completionHandler(nil) completionHandler(nil)
// } } else {
completionHandler(nil)
}
#else #else
let client = CWWiFiClient.shared() let client = CWWiFiClient.shared()
let ssid = client.interfaces()?.compactMap { $0.ssid() }.first let ssid = client.interfaces()?.compactMap { $0.ssid() }.first