我遇到一个问题,如果另一个应用程序已打开其vpn,则当iPhone进入我的应用程序时,我的应用程序的vpn会发生错误。
以下是我的代码:
[NETunnelProviderManager loadAllFromPreferencesWithCompletionHandler:^(NSArray<NETunnelProviderManager *> * _Nullable managers, NSError * _Nullable error) {
if (managers.count > 0) {
self.vpnManager = managers[0];
log4cplus_error("TVU_Router", "%s - The vpn already configured. We will use it.",ModuleName);
return;
}else {
log4cplus_error("TVU_Router", "%s - The vpn config is NULL, we will config it later.",ModuleName);
}
[self.vpnManager loadFromPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error != 0) {
const char *errorInfo = [NSString stringWithFormat:@"%@",error].UTF8String;
log4cplus_error("TVU_Router", "%s - applyVpnConfiguration loadFromPreferencesWithCompletionHandler Failed - %s !",ModuleName,errorInfo);
return;
}
NETunnelProviderProtocol *protocol = [[NETunnelProviderProtocol alloc] init];
protocol.providerBundleIdentifier = self.vpnConfigurationModel.tunnelBundleId;