When I call fetchCurrent on NEHotspotNetwork, I am able to correctly retrieve the SSID and other information, but why do I always receive zero as the signal strength value?
Here my code:
let config = NEHotspotConfiguration(ssid: "mySSID", passphrase: "MyPass", isWEP: false)
config.joinOnce = true
NEHotspotConfigurationManager.shared.apply(config) { [weak self] (error) in
guard let this = self else {
print("WiFi network not found")
result(false)
return
}
this.getSSID { (sSSID) -> () in
if (error != nil) {
if (error?.localizedDescription == "already associated.") {
print("Connected to '\(sSSID ?? "<Unknown Network>")'")
result(true)
} else {
print("Not Connected")
result(false)
}
} else if let ssid = sSSID {
print("Connected to " + ssid)
// ssid check is required because if wifi not found (could not connect) there seems to be no error given
result(ssid == sSSID)
} else {
print("WiFi network not found")
result(false)
}
}
}
} else {
print("Not Connected")
result(nil)
return
}
public func getSSID(result: @escaping (String?) -> ()) {
if #available(iOS 14.0, *) {
NEHotspotNetwork.fetchCurrent { currentNetwork in
result(currentNetwork?.ssid)
}
}
}