根据要求,iOS应用程序需要识别当前连接的网络,无论是打开的还是密码保护的,并向用户显示警告消息。
我已经浏览了下面的链接,但无法使其工作https://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618930-issecure我收到了苹果公司的授权,但看不到任何样品项目。
我希望代码应该类似于下面的(只是为了让问题清楚,而不是真正的代码(
let network = NEHotspotNetwork() // get the currently connected network
let isSecured = network.isSecure // get the current security
print("isSecure (isSecured)") //printing the security is password protected or not
实现需要考虑的几件事
-
向苹果请求授权
-
您的设备目标是iOS 14。*
-
下方的代码
if #available(iOS 14.0, *) { NEHotspotNetwork.fetchCurrent { network in if let network = network { print("is secured ((network.isSecure))") } } }