gpt4 book ai didi

ios - NEVPNManager按需回调

转载 作者:行者123 更新时间:2023-12-01 18:50:01 24 4
gpt4 key购买 nike

我有一个问题
loadPreferencesWithCompletitionHandler

savePreferencesWithCompletitionHandlerNEVPNManager

例如,在按需连接建立时是否调用此功能的块?

如果是,那么它会触发应用激活吗?

如果不是,那么在VPN连接之前需要做一些准备怎么办?

我可以在连接之前设置某种回调吗?

最佳答案

不。您误解了此功能块的目的。

完成适当的操作(加载或保存vpn配置)并为您提供NSError对象时,将调用它们,以帮助您了解操作是否成功。

到目前为止,正如我从官方文档和实验中发现的那样,尚无官方方法可以实现您想要做的事情(在连接之前进行设置回调)。

但是,在您的应用程序处于 Activity 状态时,您可以订阅NEVPNStatusDidChangeNotification通知并通过NEVPNManager检查连接状态:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeVpnStatus) name:NEVPNStatusDidChangeNotification object:nil];

和didChangeVpnStatus方法:
NEVPNManager * vpnManager = [NEVPNManager sharedManager];
switch (vpnManager.connectionStatus) {
case NEVPNStatusInvalid:
break;
case NEVPNStatusDisconnected:
break;
case NEVPNStatusConnecting:
break;
case NEVPNStatusConnected:
break;
case NEVPNStatusReasserting:
break;
case NEVPNStatusDisconnecting:
break;
}

关于ios - NEVPNManager按需回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31804291/

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