Custom sdk dependencies

Customize the SDK internal logic

  1. Create a Configuration File. Define a raw resource file named sdk_deps.json to specify custom dependencies. General structure of dependencies config may look like:

{
  "dependency 1 key": {
    "type": "class 1 name for dependency to use"
  },
  "dependency 2 key": {
    "type": "class 2 name for dependency to use"
  }
}
  1. Set up metadata in AndroidManifest.xml. Add the following code to the <application> section of your AndroidManifest.xml to link the configuration file:

<meta-data
         android:name="unified.vpn.sdk.deps"
         android:resource="@raw/sdk_deps"/>
  1. Configure ProGuard. Make sure that your custom dependency classes are not renamed or removed by ProGuard or other code obfuscation tools.

Possible dependencies overrides

You can override various SDK dependencies by creating custom classes and specifying them in the sdk_deps.json file. Below is an example of overriding the SDK's logging functionality.

Custom logger

  1. Define a class that extends unified.vpn.sdk.UnifiedLogDelegate. This class will handle logging for the SDK:

Configure the SDK to Use the Custom Logger: Add the following entry in your sdk_deps.json file to specify the custom logger class:

Additional configuration of OkHttpClient used in sdk

  1. Define class that implements OkHttpNetworkLayer.HttpClientConfigurer

  1. Setup SDK dependency override in sdk_deps

Custom backend URL rotator

  1. Create a Custom URL Rotator: Define a class that implements the UrlRotator interface. This class controls the behavior for rotating backend.

  1. Create a URL Rotator Factory: Define a class that implements the UrlRotatorFactory interface, which creates instances of your custom UrlRotator

  1. Configure the SDK to Use the Custom URL Rotator: Update the sdk_deps.json file to specify the custom URL rotator factory.

Custom notification builder

You can customize how notifications are displayed by defining your own notification builder. Follow these steps to set up a custom notification delegate:

  1. Create a Custom Notification Delegate Class: Define a class that implements the NotificationDelegate interface. This class controls the appearance and behavior of notifications related to VPN activity.

  1. Configure the SDK to Use the Custom Notification Delegate: Update the sdk_deps.json file to specify your custom notification delegate class.

Last updated

Was this helpful?