在从iOS 12传递到13之后,我不再能够获得连接的wifi网络的SSID。
我尝试了在this question中提出的this question 13的解决方案,但没有结果。
我以前为iOS 12编写的成功代码(此外,“CaptiveNetwork”现在不再推荐):
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;
}
}
}有什么建议吗?
发布于 2019-11-06 07:10:59
更新为iOS 13:苹果宣布iOS 13,CNCopyCurrentNetworkInfo API将不再返回有效的will和BSSID信息。
如果您的应用程序需要有效的Wi和BSSID信息才能正常工作,您可以执行以下操作:·对于附件安装应用程序,请使用NEHotSpotConfiguration API,它现在可以选择传递应用程序希望连接到的SSID热点的前缀。·对于其他类型的应用程序,使用CoreLocation API请求用户同意访问位置信息。
因此,我以以下方式更新了上述解决方案:
将此键添加到您的info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your Description</string>使用CoreLocation API请求用户同意访问位置信息。
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();
}在调用“GetLocationConsent”之前调用CaptiveNetwork()函数。
https://stackoverflow.com/questions/58542114
复制相似问题