Mik*_*keB 14 ios captivenetwork swift nehotspothelper ios13
Apple更改了有关iOS 13中WiFi的一些内容。如果要使用CNCopyCurrentNetworkInfo,则您的应用程序需要具有以下任一功能
资料来源:WWDC 19会议713
我正在使用NEHotspotConfiguration配置网络,但这样做后无法再获取当前的SSID。
以下代码在iOS 12上运行良好:
/// retrieve the current SSID from a connected Wifi network
private func retrieveCurrentSSID() -> String? {
let interfaces = CNCopySupportedInterfaces() as? [String]
let interface = interfaces?
.compactMap { [weak self] in self?.retrieveInterfaceInfo(from: $0) }
.first
return interface
}
/// Retrieve information about a specific network interface
private func retrieveInterfaceInfo(from interface: String) -> String? {
guard let interfaceInfo = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: AnyObject],
let ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
else {
return nil
}
return ssid
}
Run Code Online (Sandbox Code Playgroud)
在iOS 13中,CNCopyCurrentNetworkInfo始终返回nil。
我的应用程序具有访问WiFi信息功能集。
谢谢你的帮助!
Rob*_*eny 13
正如我在Apple开发者论坛上所说,CNCopyCurrentNetworkInfo现在的使用受到限制。
查看WWDC 19会议713,网络方面的进展,第2部分(可能是演示过程的75%)。CNCopyCurrentNetworkInfo现在仅在以下三种情况下可用于您的应用程序:
如果您不满足这些条件中的至少一项,CNCopyCurrentNetworkInfo则始终会nil在iOS 13中返回。
更新:从iOS 13 Developer Beta 6开始,Apple终于更新了文档以记录更改。
| 归档时间: |
|
| 查看次数: |
8574 次 |
| 最近记录: |