0 Replies
      Latest reply on Feb 12, 2020 4:42 PM by davinderfromzirakpur
      davinderfromzirakpur Level 1 Level 1 (0 points)

        I am using NetworkExtension and creating/managing a Personal VPN configuration that uses IKEv2 built-in VPN protocol.

        When I connect the VPN from my app it give me connectedDate from that i am getting time stamp to show the timer like 00:00:00 which will start when the VPN is connected

        After connecting VPN I put the app in the background, Then I open the settings app and I disconnect and connect the VPN again from the General->VPN. After that when I open the app again the connectedDate I am getting is still the same(first time VPN connected).

         

        My VPN profile is configured successfully and I am calling loadTheVPNPreferencesOnly() in applicationDidBecomeActive

        func loadTheVPNPreferencesOnly() {
          NEVPNManager.shared().loadFromPreferences { (error) in
          if error != nil {
          print(error.debugDescription)
          }
          else {
          print("No error from loading VPN viewDidLoad")
          }
          }
          print("adding NEVPNStatusDidChange Observer.... ")

          //OBSERVER TO CHECK THE VPN CONNECTION STATUS....

          self.addConnectionObserver()
          }

        I also tried like this, But the
        connectedDate is still previous one:
        let VPNConnecteddate = NEVPNManager.shared().connection.connectedDate
        //print(VPNConnecteddate as? Date) // 2020-01-30 14:46:56 +0000
        let VPNTimeStamp = VPNConnecteddate?.timeIntervalSince1970
        if VPNTimeStamp != nil {

          CommonMethod.saveUserDefault(key: "vpnTimeStamp", value: VPNTimeStamp)

          print("VPNTimeStamp===> \(VPNTimeStamp)")
        }


        I will really appreciate if someone helps me on this point. I have searched a lot for checking this online.

        Links you can take as reference:

         

        https://stackoverflow.com/questions/39056600/nevpnmanager-check-is-connected-after-restart-the-app/47689509

        https://stackoverflow.com/questions/47409401/create-personal-vpn-connection-using-nevpnmanager