CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.

AVVPNService 0.1.4

AVVPNService 0.1.4

Maintained by Andrey Vasilev.



  • By
  • Andrey Vasilev

AVVPNService

Version License Platform

Requirements

  • iOS 9.3+
  • Swift 5

Installation

AVVPNService is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AVVPNService'

or just add AVVPNService/Classes/ to your project

Usage

Select Signing & Capabilities pane of the project editor -> Add Personal VPN capability

import AVVPNService

// Initialize Credentials
let credentials = Credentials.IPSec(server: "", username: "", password: "", shared: "")
// or
let credentials = Credentials.IKEv2(server: "", username: "", password: "", remoteId: "", localId: "")

// Connect
AVVPNService.shared.connect(credentialas) { error in
// Handle error
}

//Disconnect
AVVPNService.shared.disconnect()

You can also observe NEVPNStatus

import AVVPNService
import NetworkExtension

// Set delegate
AVVPNService.shared.delegate = self

// and conform to AVVPNServiceDelegate
func vpnService(_ service: AVVPNService, didChange status: NEVPNStatus)

Or subscribe NEVPNStatusDidChange notification

import AVVPNService
import NetworkExtension

NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatus(_:)), name: NSNotification.Name.NEVPNStatusDidChange, object: nil)

@objc func didChangeStatus(_ notification: Notification) {
    if let connection = notification.object as? NEVPNConnection {
        print(connection.statu)
    }
}

Author

Andrey Vasilev ([email protected])

Credits

Create a key chain for Apple's VPN, Moataz Elmasry

License

AVVPNService is available under the MIT license. See the LICENSE file for more info.