I need to get ssid of currently connected network. The reason I need this is to enable my app to perform certain functions when connected to a specific network. Now I cant seem to figure it out as in how to get the ssid? I've read online and implemented following things.
-> Allowed user location
-> Logged in to Apple dev account and enabled Wifi access.
The function I am using is
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedAlways || status == .authorizedAlways {
NEHotspotNetwork.fetchCurrent { hotspotNetwork in
if let ssid = hotspotNetwork?.ssid {
print("SSID is \(ssid)")
}
}
}
}
But it is giving the following error
NEHotspotNetwork nehelper sent invalid result code [5] for Wi-Fi information request
What else am I missing here? Do i need to add anything else? Appreciate any help!
I have sorted out the way to get SSID of currently connected Wifi. Following are the pre-requisites to follow before writing the code.
-> You must have a paid developer account.
-> You must have a physical Device
-> You must enable Wifi-Entitlement by going to
Target->Signing & Capabilitiesand addingAccess WiFi Informationor adding<key>com.apple.developer.networking.wifi-info</key> <true/>directly to your entitlements file.-> Allow location usage access from user
Then use this code in your class to get SSID.