gpt4 book ai didi

ios - NetworkExtension VPN iOS 将蜂窝网络更改为 Wifi

转载 作者:行者123 更新时间:2023-11-30 11:24:57 28 4
gpt4 key购买 nike

我正在编写一个管理 VPN 的 NetworkExtensions 应用程序。当从 WiFi 切换到蜂窝网络或反之亦然时,管理 VPN 的正确方法是什么?

目前,我正在通过可达性 ( https://github.com/ashleymills/Reachability.swift ) 并使用 NEVPNStatus.reasserting 来检测网络变化。这是最好的办法吗?

谢谢!

最佳答案

您可以为此目的设置网络接口(interface)观察程序。

它最初应该得到 current active interfaces (不包括 utun),然后每秒触发一次以再次获取事件接口(interface)。比较“旧”和"new"界面的有序集合,观察者可以判断用户是否在 WiFi 和蜂窝网络之间切换。

NOTE: You might also find it useful to monitor SSID name of current WiFi network too.

关于ios - NetworkExtension VPN iOS 将蜂窝网络更改为 Wifi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50843512/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com