1

I want to implement code for scan the nearby wifi devices. I am not getting proper solution for this after doing lots of research. Can you please give me proper solution to scan the nearby wifi devices? I have implemented below code. It only getting information of wifi which is already connected. Below is the code:

func getInterfaces() -> Bool {
    guard let unwrappedCFArrayInterfaces = CNCopySupportedInterfaces() else {
        print("this must be a simulator, no interfaces found")
        return false
    }
    guard let swiftInterfaces = (unwrappedCFArrayInterfaces as NSArray) as? [String] else {
        print("System error: did not come back as array of Strings")
        return false
    }
    for interface in swiftInterfaces {
        print("Looking up SSID info for \(interface)") // en0
        guard let unwrappedCFDictionaryForInterface = CNCopyCurrentNetworkInfo(interface as CFString) else {
            print("System error: \(interface) has no information")
            return false
        }
        guard let SSIDDict = (unwrappedCFDictionaryForInterface as NSDictionary) as? [String: AnyObject] else {
            print("System error: interface information is not a string-keyed dictionary")
            return false
        }
        print(SSIDDict)
    }
    return true
}

It return output is below.

Looking up SSID info for en0
["SSIDDATA": <4575726f 74726f6e 6963>, "BSSID": d4:3d:37:14:9:2f, "SSID": Vikas]

Can you please help me to scan the nearby wifi devices functionality?

Vikas
  • 1,548
  • 2
  • 12
  • 25
  • https://stackoverflow.com/questions/49525912/how-to-get-available-all-wifi-network-name-listing-in-ios-using-swift – Vishnu Dec 22 '20 at 06:54
  • Tried this. It only shows networks that are connected. I want to scan nearby all devices. – Vikas Dec 22 '20 at 07:00

0 Answers0