I know it's not possible to get all available Wi-Fi networks and it's possible to get the information of current connected Wi-Fi network, correct me if I'm wrong.
I just want to know the feasibility of getting the information of all previously connected Wi-Fi networks, Please help me by sharing your experience.
FYI,
I'm using the following code get current connected Wi-Fi network's info and it's working fine.
var currentSSID: String!
let interfaces:CFArray! = CNCopySupportedInterfaces()
for i in 0..<CFArrayGetCount(interfaces) {
let interfaceName: UnsafePointer<Void>
= CFArrayGetValueAtIndex(interfaces, i)
let rec = unsafeBitCast(interfaceName, AnyObject.self)
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)")
if unsafeInterfaceData != nil {
let interfaceData = unsafeInterfaceData! as Dictionary!
currentSSID = interfaceData["SSID"] as! String
} else {
currentSSID = ""
}
print(currentSSID)
}
From a stock iPhone this is not possible from the settings. The information that you want is stored in the iPhone's keychain. If you have access to the iPhone SDK you can start messing around if you like, but I will leave it at that since that would be a StackOverflow answer. Source
If you have ICloud Keychain enabled, it is possible to fetch this data. Otherwise, you can't. Source You can use kishikawakatsumi/KeychainAccess or do it yourself. Here is homemade code to save and retrieve keychain values. It is a simple swift wrapper for Keychain that works on iOS and OS X