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?
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 …
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.
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 )
To test this you need a physical device (iPhone) connected to your pc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With