Search code examples
iosobjective-cnevpnmanager

How to detect if NEVPNManager configuration is installed?


I am working with VPN on iOS using the NetworkExtension framework. I am able to install the config and make connection. My question is if there's a way to detect if the VPN config is still installed or detect if user has un-installed the config?

I am not necessarily looking for a notification or anything in the background but what I am looking for is some method/workaround that I do when the application is brought to foreground?

I'm using certificate authentication with a certificate issued by an intermediate CA and have tried 'evaluating trust' method from here: Check if a configuration profile is installed on iOS

This did not work for me. I always comes to be trusted. I have also tried this:

if([NEVPNManager sharedManager].protocol){
   //installed
}else{
   //not installed
}

But this also does not work. After uninstallation the protocol remains valid. If I quit and relaunch the app then the protocol is invalid.

Any suggestions are appreciated.


Solution

  • You can try following

    if ([[[NEVPNManager sharedManager] connection] status] == NEVPNStatusInvalid) {
        //...
    }