Created
May 24, 2018 14:58
-
-
Save GregoryMaks/5b3b5aa5294d24ee0ed2aad15eb1a43f to your computer and use it in GitHub Desktop.
Get WiFi SSID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func currenthWiFiSSIDInfo() -> String? { | |
if let interfaces = CNCopySupportedInterfaces() { | |
for i in 0..<CFArrayGetCount(interfaces){ | |
let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interfaces, i) | |
let rec = unsafeBitCast(interfaceName, to: AnyObject.self) | |
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString) | |
if let unsafeInterfaceData = unsafeInterfaceData as? Dictionary<AnyHashable, Any> { | |
logger(unsafeInterfaceData["SSIDDATA"].debugDescription) | |
return unsafeInterfaceData["SSID"] as? String | |
} | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment