ios - wifi不存在时NEHotspotConfigurationManager报错问题

标签 ios swift networkextension

当我尝试连接不存在的 wifi 时发现问题,这是我的代码:

let configuration = NEHotspotConfiguration.init(ssid: "wifi-name")  
 NEHotspotConfigurationManager.shared.apply(configuration) { [unowned self] (error) in  
       print("NEHotspotConfigurationManager.error: \(error)")  
   }

如果 wifi 不存在,我会看到并与之对话

"impossible to connect network "wifi-nam""

但是NEHotspotConfigurationManager中的错误为nil,那么如何控制特定ssid wifi是否存在?

最佳答案

不幸的答案是:您无法控制特定 WiFi 是否存在。

这是预期的行为。如果您可以检查附近是否有某个 wifi,则可以使用该信息来跟踪用户。这就是为什么如果你想这样做,Android 会要求位置权限。在 iOS 上,这目前根本不可能。

关于ios - wifi不存在时NEHotspotConfigurationManager报错问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52642814/

相关文章:

objective-c - Xcode Git 与 Google Drive/Dropbox 的问题

iphone - 在内部类中引用 iVar 时出现问题

objective-c - UITapGestureRecognizer选择器,sender是手势,不是ui对象

ios - 使用 App Extension 的 VPN 连接

ios - 为什么 SKSpriteNode node.frame.size.width 小于 node.size.width?

ios - 解析 JSON 数组的问题

arrays - Swift 可变数组线程安全

ios - 移动 map View 后如何保持用户位置居中

swift - NETunnelProviderManager loadAllFromPreferences 零管理器返回