Skip to content

Instantly share code, notes, and snippets.

@werediver
Created July 14, 2016 12:47
Show Gist options
  • Select an option

  • Save werediver/b1d5ed625a3fbf538481e40a71b4d1ac to your computer and use it in GitHub Desktop.

Select an option

Save werediver/b1d5ed625a3fbf538481e40a71b4d1ac to your computer and use it in GitHub Desktop.
Get the connected Wi-Fi network SSID on iOS (in Swift).
import Foundation
import SystemConfiguration.CaptiveNetwork
func getWiFiSsid() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
}
}
}
return ssid
}
@wving5
Copy link
Copy Markdown

wving5 commented Mar 27, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment