CNCopyCurrentNetworkInfo 不适用于 iOS 14

Mah*_*dam 5 wifi ios ios14

我有一个使用 WIFI 连接到外部设备的应用程序,我曾经通过检查 WIFI SSID 来验证 iPhone 是否已连接到设备。这在 iOS 13 发布时被阻止,我通过请求获取 SSID 的位置权限来修复它。

我现在尝试使用启用了位置服务的 iOS 14 测试版,但无法获取 WIFI SSID,但是相同的代码适用于 iOS 13。

这是我打电话时得到的日志 CNCopyCurrentNetworkInfo

nehelper sent invalid result code [1] for Wi-Fi information request

nehelper sent invalid response: <dictionary: 0x1e815f3e0> { count = 1, transaction: 0, voucher = 0x0, contents =
    "XPCErrorDescription" => <string: 0x1e815f548> { length = 18, contents = "Connection invalid" }
}

nehelper sent invalid response for Wi-Fi information request: <dictionary: 0x1e815f3e0> { count = 1, transaction: 0, voucher = 0x0, contents =
    "XPCErrorDescription" => <string: 0x1e815f548> { length = 18, contents = "Connection invalid" }
Run Code Online (Sandbox Code Playgroud)

知道如何解决这个问题吗?谢谢


更新:只有在请求位置访问时打开了精确位置才有效

小智 1

CNCopyCurrentNetworkInfo 对于 ios14 已弃用 CNCopyCurrentNetworkInfo (CFStringRef interfaceName) API_DEPRECATED_WITH_REPLACEMENT("[NEHotspotNetwork fetchCurrentWithCompletionHandler:]", ios(4.1, API_TO_BE_DEPRECATED), macCatalyst(14.0, API_TO_BE_DEPRECATED))