Disable on-demand VPN

Hi There,

We want to disable on-demand feature when the packet tunnel provider is stopped, so we implemented the logic like this:

- (void)stopTunnelWithReason:(NEProviderStopReason)reason
           completionHandler:(void (^)(void))completionHandler {
[NETunnelProviderManager 
   loadAllFromPreferencesWithCompletionHandler:^(
    NSArray *managers, NSError *error) {
    NETunnelProviderManager *manager = 

        managers.firstObject;  
    [manager setOnDemandEnabled:NO];
    [manager 
        saveToPreferencesWithCompletionHandler:
           ^(NSError *saveError) {
              completionHandler();
       }];
    }];
}

However, when the user turns off VPN from the Settings app, the completion handler in the loadAllFromPreferencesWithCompletionHandler is not executed. Do you have an idea why is that?

However, when the user turns off VPN from the Settings app, the completion handler in the loadAllFromPreferencesWithCompletionHandler is not executed. Do you have an idea why is that?

It looks like this is being done in the provider. If your container app is alive and you detect that your NEVPNStatus has gone into the state of NEVPNStatusDisconnected, and you update the NETunnelProviderManager settings there, does this take affect then?

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

What are you trying to do here and why are you trying to do something like this in the packet tunnel provider?

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

I am trying to disable on-demand feature when VPN stops for a specific NEProviderStopReason and yes I am trying to achieve when -stopTunnelWithReason: completionHandler: is called because this is the only method that is guaranteed to be called when the VPN stops on iOS

Is there a reason you need to disable your On Demand feature?

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Disable on-demand VPN
 
 
Q