How to determine if NEVPNManager is installed?

I work with VPN on iOS using the NetworkExtension infrastructure. I can install the configuration and establish the connection. My question is, is there a way to determine if the VPN configuration is installed, or is it detected if the user has not installed the configuration?

I'm not necessarily looking for a notification or something in the background, but what am I looking for is the method / workaround that I do when the application comes to the fore?

I use certificate authentication with a certificate issued by an intermediate CA, and tried the "trust assessment" method from here: Check if the configuration profile is installed on iOS

This did not work for me. They always trust me. I also tried this:

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

But that doesn't work either. After removal, the protocol remains valid. If I leave and restart the application, the protocol will be invalid.

Any suggestions are welcome.

+4
source share
2 answers

You can try to run

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

It might be a little late. But I ran into the same problem. However, your approach led me in the right direction. You must load it into the completion handler:loadFromPreferencesWithCompletionHandler

The subroutine uses, in my opinion, checking for the presence of an installed profile:

   manager = [NEVPNManager sharedManager];

   [manager loadFromPreferencesWithCompletionHandler:^(NSError *error) {
       if (manager.protocol == nil) {
           NSLog(@"Profile is not installed, you might want to install a profile");
       } else {
           NSLog(@"Profile is installed. It looks like this: %@",manager.protocol);
       }
   }];
+1
source

All Articles