Last active
October 4, 2019 17:41
-
-
Save joshua24322/b0d19952990f3c3b111738efceb70b28 to your computer and use it in GitHub Desktop.
Get current SSID by CF-based APIs
This file contains hidden or 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
// https://forums.developer.apple.com/thread/50302 | |
func getSSID() -> [String] { | |
guard let interfacesName = CNCopySupportedInterfaces() as? [String] else { return [String()] } | |
return interfacesName.compactMap({ (name) in | |
guard let info = CNCopyCurrentNetworkInfo(name as CFString) as? [String: AnyObject] else { return nil } | |
guard let ssid = info[kCNNetworkInfoKeySSID as String] as? String else { return nil } | |
return ssid | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment