Pango Platform
HomeConsole
  • What is Pango Developer Platform
  • Getting started
    • Sign up on the Management Console
    • Create a new project
    • Switch projects
    • Change console settings
    • Edit your profile
    • Try out the demo app
    • Keep exploring
    • Deprecation and Sunset
  • Console details
    • Dashboard
      • General
      • Location loading
    • Users
      • User page
    • Active sessions
    • Network
      • Countries
      • Locations
      • Pools
        • Optimal location
        • Location rules
    • Settings
      • General
        • Project config description (JSON format)
          • Server selector (JSON format)
          • Request selector (JSON format)
      • Authentication methods
        • Auth Plugin requirements
      • VPN
        • General
        • VPN Bypass list
        • Client Networks
      • Member
    • Export Data
    • Log
  • SDK
    • Unified VPN SDK for Android
      • Setup
        • Application Setup
        • Proguard Rules, Notification, and Analytics Configurations
        • Backend URL Configuration
      • Usage
        • Initialization
        • VPN Interface
        • Backend interface
      • Features
        • Hydra Protocol
          • Location profile (Hydra only)
        • Custom sdk dependencies
        • Deferred VPN Service Initialization
        • Authentication
        • Client Network List (CNL)
        • OpenVPN transport
        • Wireguard Transport
        • Reconnection strategy
        • Single Protocol SDK
        • Killswitch
        • Domain route via VPN
        • Process route via VPN
        • Process Bypass
        • Domain Bypass
        • Traffic rules
        • VPN Node DNS Configuration
        • Multihop
          • Optimal Location
      • Exceptions
      • Version migration
      • Changelog
    • Unified VPN SDK for Apple
      • Setup
        • Application Setup
        • Network Extension Setup
          • Network Extension Setup for tvOS
        • Backend URL Configuration
      • Usage
        • Single Protocol SDK
        • Unified SDK
        • Logging
        • Decoding Encoded VPN SDK Logs
      • Features
        • Deferred VPN Service Initialization
        • Authentication
        • Wireguard Transport
        • Reconnection strategy
        • Killswitch
        • Domain Bypass
        • Multihop
          • Optimal Location
        • Client Network List (CNL)
        • Domain route via VPN
      • Changelog
      • API Reference
    • IPSEC VPN SDK for Apple
    • Unified VPN SDK for Windows
      • Setup
        • Backend URL Configuration
        • Service command line arguments
        • ARM Platform Support
      • Usage
        • CoreAPI
        • Events
        • Generating a Unique Device Identifier
        • Error processing
        • Pipe Messaging
      • Features
        • Traffic protection
          • Killswitch
          • Prevent IP Leaks
          • Block Local Networks
        • Other
          • Firewall
            • DNS Monitor
            • Process Bypass
            • Domain Bypass
            • Process route via VPN
            • Domain route via VPN
          • Throttling
          • Optimal Location
          • Common issues
        • Hydra Protocol
          • CustomDNS, UserDNS, MultiHop, VpnProfiles
        • OpenVPN Protocol
        • Wireguard Protocol
        • IPSec Protocol
      • Collecting Debug Logs
      • Changelog
    • Unified VPN SDK for Routers
      • SDK. Shared library.
      • Configuration Interface (CI)
        • Unix Domain Sockets CI
        • REST API CI
    • Unified VPN SDK Feature Comparison By Platform
    • Unified VPN SDK
      • Features
        • Personal Bridge
    • Tunnel Vision and Tunnel Crack Prevention
  • REST API
    • Partner API
  • Sample applications
    • Unified VPN SDK demo for Windows
    • Hydra VPN SDK demo for iOS
    • IPSEC VPN SDK demo for iOS
    • Unified VPN SDK demo for Android
    • Hydra VPN SDK demo for OpenWRT
    • OpenVPN configuration file
  • Resources
    • Use cases
      • Public VPN
      • Business VPN
        • Creating a Business VPN Project
        • Wi-Fi Security for Business
      • Application anti-blocking
    • How-to
      • Create a Firebase project for User Authentication
      • AWS CloudFront Distribution of the Platform URL
      • How can I get Shared Secret key from iTunes Connect for In-App Purchase
  • FAQ
    • General
      • VPN Platform Flow
      • What data is collected by the Platform?
      • What analytic data is collected by your SDK?
      • How the Platform restricts access to our data?
      • Why DNS Leak tests often indicate positive result?
      • Do we need to perform endpoint health checks?
      • How is the VPN exit node found?
      • How are streams re-marked if VPN is enabled/disabled on an active flow?
      • Is there a maximum number of supported devices?
      • Are both IPv4 and IPv6 supported?
      • What is the MTU of the tunnel?
      • Are any redundancy measures in terms of reliability provided?
      • Is there any load balancing?
      • Do you block broadcast and multicast to/from the VPN?
    • List of Open Source libs
Powered by GitBook
On this page
  • API Documentation
  • Table of Contents
  • Integration
  • Start using Unified SDK

Was this helpful?

  1. SDK
  2. Unified VPN SDK for Apple
  3. Usage

Unified SDK

PreviousSingle Protocol SDKNextLogging

Last updated 1 month ago

Was this helpful?

Allows to use different VPN protocols inside one app and switch between them more easily.

API Documentation

To see all available API, check API Reference.

Table of Contents

Integration

Unified SDK supports all protocols that you can use with single protocol SDK separately: Hydra, IPSec, WireGuard. So intergation process includes:

  1. Setup application target

  2. Setup network extension target for every protocol you want to support.

Start using Unified SDK

There are 2 ways how you can use Unified SDK: manual protocol switching (through ManualSwitchingVPNSDK) and auto switching (through AutoSwitchingVPNSDK).

Manual switching SDK

Manual switching SDK provides ability to change VPN protocol at any moment by user requirement.

Configure manual switching SDK

To start using the SDK, you need to import import VPNApplicationSDK to your file under the application target.

Unified SDK requires that at least 2 different available SDK types should be provided to configuration. For instance, in order to use Hydra and IPSec protocols together you can specify following configuration:

import VPNApplicationSDK
// ...
    
let configuration = UnifiedConfiguration(
    availableTypes: [
        .hydra(extensionBundleID: "HYDRA_NETWORK_EXTENSION_BUNDLE_ID"),
        .ipsec
    ],
    carrierID: "CARRIER_ID",
    groupData: VPNGroupData(
        groupID: "group.GROUP_ID",
        usesSystemExtension: false
    ),
    profileName: "PROFILE_NAME",
    fireshieldConfig: fireshieldConfig,
    isOnDemandEnabled: true,
    isVPNIconFixEnabled: true
)

let initialProtocolType = VPNProtocolType.hydra // This protocol will be set as active after SDK init

self.unifiedSDK = ManualSwitchingVPNSDK(configuration: configuration, initialProtocolType: initialProtocolType)

The best place to put initialization code is you AppDelegate's application:didFinishLaunchingWithOptions:.

Switch VPN protocol manually

You can use func switchToProtocol(_ newProtocolType: VPNProtocolType, completion: ((_ error: Error?, _ activeSDK: VPNSDK?) -> Void)?) method to change VPN protocol. If VPN is connected at the moment of call, it will be stopped and then reconnected to the same location after protocol change. This method also provides logic that helps to resolve some annoying problems related to protocols changing (e.g., unwanted On Demand functionality from old protocol).

Auto switching SDK

Auto switching SDK modifies VPN start flow in a way when it can fallback to different VPN protocols depending on provided protocol priority.

Configure auto switching SDK

Auto switching SDK is build upon manual switching SDK and uses it to switch between VPN protocols when needed. So you should initialize ManualSwitchingVPNSDK and use it with priority provider as parameters for AutoSwitchingVPNSDK init:

import VPNApplicationSDK
// ...
    
let manualSwitchingSDK = // ...

// This closure will be called at the beginning of start flow to determine VPN protocols order
let priorityProvider: AutoSwitchingVPNSDK.PriorityProvider = {
    return [.hydra, .ipsec]
}

self.unifiedSDK = AutoSwitchingVPNSDK(manualSwitchingSDK: manualSwitchingSDK, priorityProvider: priorityProvider)

Logging in

After SDK is initialized, you need to login to be able to start VPN. If you are using OAuth authentication, provide your own OAuth dialogs UI and receive OAuth access token. Login example with OAuth token:

import VPNApplicationSDK
// ...

let unifiedSDK: ManualSwitchingVPNSDK // or AutoSwitchingVPNSDK
// ...

let authMethod = AuthMethod(type: .oauth, token: "OAUTH_TOKEN")

unifiedSDK.login(method: authMethod) { error, user in
    print("isLogged: \(error == nil)")
}

See AuthMethod in API reference for more authentication methods.

Connecting VPN and obtaining status

To connect VPN you can use function start(location:completion:) (the same as for single protocol SDKs). When VPN is started or an error occurred, completion handler will be called. To obtain VPN connection status you need to subscribe to vpnStateDidChange notification provided by SDK. For example:

NotificationCenter.default.addObserver(forName: .vpnStateDidChange, object: nil, queue: nil) { notification in
    // ...
}

When you receive notification, get updated VPN status from SDK instance state property and handle this status as designed by your app.

Active VPN protocol autocorrection

Sometimes you can face situation when value of active protocol type inside SDK became out of sync with actual active protocol type (for example, if you did set active protocol to .hydra, but then user started IPSec connection from iOS settings). In such cases SDK will automatically change value of active protocol type to the actual value.

Detection of protocol change

You can observe VPN protocol changes (both manual and auto) by subscribing to vpnProtocolDidChange notification. When you receive notification, get updated protocol type from activeProtocolType SDK instance property.

Integration
Manual switching SDK
Configure manual switching SDK
Switch VPN protocol manually
Auto switching SDK
Configure auto switching SDK
Loggin in
Connecting VPN and obtaining status
Active VPN protocol autocorrection
Fireshield features