Initialization

To use the UnifiedSDK in your Android application, you must initialize it with your VPN backend URLs and carrier ID. You carrier ID is the unique project name that is assigned to your company when you access pango-cloud.com.

Initial SDK Setup

To initialize the UnifiedSDK in your Android application, use the following:

Java

ClientInfo clientInfo = ClientInfo.newBuilder()
    .addUrl("http://yourvpnbackend.com") // add urls for api calls
    .carrierId("YOUR_CARRIER_ID") // set your carrier id
    .build();

UnifiedSdk sdk = UnifiedSdk.getInstance(clientInfo);

Kotlin

val clientInfo = ClientInfo.newBuilder()
   .addUrl("http://yourvpnbackend.com") // add urls for api calls
   .carrierId("YOUR_CARRIER_ID") // set your carrier id
   .build()

val sdk = UnifiedSdk.getInstance(clientInfo)

In this example:

  • Use addUrl() to specify one or more URLs for your VPN backend API endpoints. You can call addUrl() multiple times to add additional URLs.

  • Set your unique carrier ID by calling carrierId() with your carrier ID string.

Copy the code to the following:

Accessing the SDK Instance

After initializing the SDK, you can access the SDK instance from anywhere in your app code by using the following:

UnifiedSdk sdk = UnifiedSdk.getInstance();
  • You must have already initialized the SDK with a ClientInfo object before calling UnifiedSdk.getInstance() without any arguments. This method provides a convenience way to get the already-initialized SDK instance.

  • Attempting to get the SDK instance before it has been initialized will result in an error. Always make sure to initialize the SDK following the steps in the "Initial SDK Setup" section before using UnifiedSdk.getInstance() to retrieve it.

Last updated