I want to get all the WiFi networks available in a region and their SSID value. But the problem is how to get the SSID of all the WiFi network available even if I am not connected to one.
Asked
Active
Viewed 1.7k times
22
-
@EnricoSusatyo i have same problem i can't have get all available wifi list. – Jatin Devani Aug 17 '16 at 12:13
-
Not easily. Scanning wifi networks is a security threat. – Sulthan Jan 27 '17 at 21:08
-
4I found similar questions asked on SO with a quick google search, the common answer is that while you can you are not supposed to due to Apples rules – RubberDucky4444 Jan 28 '17 at 04:45
-
yeah I found one similar question here http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library – ramacode Feb 03 '17 at 10:22
3 Answers
16
iOS 12
You must enable Access WiFi Information from capabilities.
Important To use this function in iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID. Documentation link
First;
import SystemConfiguration.CaptiveNetwork
Then;
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) 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 } for d in SSIDDict.keys { print("\(d): \(SSIDDict[d]!)") } } return true }

Khaled Annajar
- 15,542
- 5
- 34
- 45
-
12This seems to only return the currently connected wifi at least on iOS 11.2.2 on an iPhone 7 – TestinginProd Jan 11 '18 at 23:14
0
Here my class that prints the WIFI network name
import UIKit
import Foundation
import SystemConfiguration.CaptiveNetwork
class FirstView: UIViewController
{
@IBOutlet weak var label: UILabel!
override func viewDidLoad()
{
super.viewDidLoad()
let ssid = self.getWiFiName()
print("SSID: \(ssid)")
}
func getWiFiName() -> 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
}
}

Leo Valentim
- 464
- 5
- 19
-
8
-
`var ssid = ""; (CNCopySupportedInterfaces() as? [CFString])?.forEach({ ssid = (CNCopyCurrentNetworkInfo($0) as? [String : Any])?[kCNNetworkInfoKeySSID as String] as? String ?? ""})` – Leo Dabus Feb 03 '17 at 07:17
0
Yes it is possible to list all nearby WiFi networks.You need to complete a questionnaire at https://developer.apple.com/contact/network-extension, and then you can use NEHotspotHelper to return a list of hotspots. Technical Q&A https://developer.apple.com/library/archive/qa/qa1942/_index.html

Rajeev Udayan
- 310
- 2
- 4