After passing from iOS 12 to 13 I am no more able to get the SSID of the connected wifi network.
I tried the solution for iOS 13 proposed in this question but with no result.
My previous successful code for iOS 12 (moreover 'CaptiveNetwork' is deprecated now):
if (CaptiveNetwork.TryGetSupportedInterfaces(out string[] supportedInterfaces) == StatusCode.OK)
{
foreach (var item in supportedInterfaces)
{
if (CaptiveNetwork.TryCopyCurrentNetworkInfo(item, out NSDictionary info) == StatusCode.OK)
{
var ssid = info[CaptiveNetwork.NetworkInfoKeySSID].ToString();
return ssid;
}
}
}
Any suggestion?
Updated for iOS 13 : Apple announced that iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information.
If your app requires valid Wi-Fi SSID and BSSID information to function, you can do the following: · For accessory setup apps, use the NEHotSpotConfiguration API, which now has the option to pass a prefix of the SSID hotspot your app expects to connect to. · For other types of apps, use the CoreLocation API to request the user's consent to access location information.
So, I updated the above solution in the following way:
Add this key to your info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your Description</string>
Use the CoreLocation API to request the user's consent to access location information.
private void GetLocationConsent()
{
var manager = new CLLocationManager();
manager.AuthorizationChanged += (sender, args) => {
Console.WriteLine("Authorization changed to: {0}", args.Status);
};
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
manager.RequestWhenInUseAuthorization();
}
Call the GetLocationConsent() function before calling the "CaptiveNetwork".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.