Extracting Wifi network information

Hi All
I am curious to know whether we can fetch the Wifi network information such as frequency or bandwidth. I am able to get the SSID and other identifiers from my ios application but i really need to know the frequency so that i can notify my user to use 2.4Ghz network instead of 5Ghz.

Thanks in advance
Rohit Nihal

@rohit.nihal Thanks very much for your question!

Try the following function:

func printCurrentWifiInfo() {
  if let interface = CNCopySupportedInterfaces() {
    for i in 0..<CFArrayGetCount(interface) {
      let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interface, i)
      let rec = unsafeBitCast(interfaceName, to: AnyObject.self)
      if let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString), let interfaceData = unsafeInterfaceData as? [String : AnyObject] {
        // connected wifi
        print("BSSID: \(interfaceData["BSSID"]), SSID: \(interfaceData["SSID"]), SSIDDATA: \(interfaceData["SSIDDATA"])")
      } else {
        // not connected wifi
      }
    }
  }
}

I hope this helps!

All the best!

This topic was automatically closed after 166 days. New replies are no longer allowed.