Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get available all wifi network name Listing in iOS using swift

I need to create an app that can get a list of all available wifi networks' names and information on their iPhone, and when the user clicks on some network they should connect to it. Can I do this, and how?

like image 232
Akash Avatar asked Mar 28 '18 04:03

Akash


People also ask

How can I get a list of available Wi-Fi networks from iOS app?

Click Wi-Fi in the sidebar, then scroll down and click Advanced at the bottom of the settings pane. In the Known Networks section, you will see a list of networks. This list shows the networks that you have connected to, and whose passwords are saved on your devices. You can delete networks by clicking the …

How can I see all available Wi-Fi networks?

Go to Start, and select Settings > Network & internet > Wi-Fi > Show available networks, and see whether your wireless network name appears in the list of available networks.


1 Answers

It is not possible to get all the available wifi networks names and information. BUT it is only possible to get the SSID (SSID is simply the technical term for a network name) of the network that you are currently connected to.

This class will show only the wifi network name you are connected to -

    import UIKit
    import SystemConfiguration.CaptiveNetwork

    class ViewController: UIViewController {

        @IBOutlet weak var label: UILabel!

        override func viewDidLoad(){
            super.viewDidLoad()
            let ssid = self.getAllWiFiNameList()
            print("SSID: \(ssid)")
        }
        func getAllWiFiNameList() -> 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
        }
    }

OUTPUT- (Network name where i am connected to )

enter image description here

To test this you need a physical device (iPhone) connected to your pc.

like image 193
Md Rashed Pervez Avatar answered Oct 15 '22 16:10

Md Rashed Pervez