Skip to main content

Getting started

Prerequisites

Before you can get started, you must first install the following software:

The SDK is made using Kotlin 2.1. If your app uses Kotlin, then we recommend that you use a language version that is the same (2.1) or newer.

The Kotlin binary format is often forwards compatible with the next Kotlin language release, but not later ones. Although this means that the minimum supported Kotlin language version is generally one version prior (2.0), we cannot guarantee compatibility.

Minimum Android version

The minimum supported Android version for the Encap SDK is Android 9.0 (API level 28).

Add the SDK to your application

Note

The Encap SDK is available from our repository. The repository is gated, therefore you require login credentials to access it.

You need to add the Encap client API to the application using Android studio and Gradle. To do this:

  1. Request your Nexus repository login credentials from us by creating a support ticket in the Signicat Dashboard.
  2. Once you have obtained access, you can set your Nexus repository login credentials:
    1. Navigate to $HOME/.gradle/gradle.properties.
    2. Set the following credentials:
      Example: Set your Nexus repository login credentials
      mavenUser=<YOUR_NEXUS_REPOSITORY_USER_ID>
      mavenPassword=<YOUR_NEXUS_REPOSITORY_PASSWORD>
  3. Add Encap as dependency in your app's build.gradle file:
Example: Add Encap as a dependency
dependencies {
implementation("com.encapsecurity:encap-android-api:3.20.3@aar")
}
  1. Add Encap as a custom repository in your project's build.gradle file.
    • For Encap SCA customers:
    Example: Add Encap as a custom repository
    allprojects {
    repositories {
    maven {
    credentials {
    username = providers.gradleProperty("mavenUser").get()
    password = providers.gradleProperty("mavenPassword").get()
    }
    url = uri("https://nexus.pub.encap.no/content/repositories/encap-partner-repository")
    }
    }
    }
    • For MobileID customers:
    Example: Add Encap as a custom repository
    allprojects {
    repositories {
    maven {
    credentials {
    username = providers.gradleProperty("mavenUser").get()
    password = providers.gradleProperty("mavenPassword").get()
    }
    url = uri("https://nexus.pub.encap.no/content/repositories/MobileID-partner")
    }
    }
    }

Load the library

Before you can use the library, it needs to be loaded. You need to do this in a way where the library is only loaded once.

For example, you could implement this using the following code:

Example: Load the library
class MyApp : Application() {
companion object {
init {
System.loadLibrary("encap-android-native-api")
}
}
}

Create a controller

The main interface of the Encap client API is the Controller. Many of the operations that you can execute with the controller are comprised of a start and finish call. For example startActivation() and finishActivation().

You can obtain the Encap controller instance using AndroidControllerFactory or AndroidLoggingControllerFactory, which are based on a singleton pattern. There can only be one instance of a specific controller with a certain name.

The first call will always create a controller. Any other calls after that will return the previously created instance.

The Controller can be created using AndroidControllerFactory:

Example: Create a controller
val controller = if (DEBUG) {
AndroidLoggingControllerFactory.getInstance(baseContext, "BankOne")
} else {
AndroidControllerFactory.getInstance(baseContext, "BankOne")
}

The log produced by AndroidLoggingControllerFactory in the code example above is available using standard Android tools.

For example, you could use the logcat tool, with tag Encap and a message level of INFO.

Notice for production

For production, you should use the no-logging factory AndroidControllerFactory and optimise/obfuscate the application so that unused classes are removed.

Note

Controllers do not share any information between themselves, so it is not possible to perform registration migrations.

A created registration will only be available on the specified controller which is identified by a name.

Configure the controller

To configure the controller, you need to create a new instance of EncapConfig, and set that on the controller.

There are three properties that you always need to set, whereas the other properties are optional.

Example: Configure the controller
controller.config = EncapConfig(
serverUrl = "https://serverurl.com", // Required
applicationId = "MyApplicationId", // Required
publicKeyBase64 = E2EE_KEY, // Required
connectionTimeout = 20000,
isClientOnly = false,
publicKeyHashes = hash,
pushToken = token,
allowDebugData = true,
locationEnabled = true,
)

MobileID customers

For MobileID customers, you must configure the following properties in the controller. This applies to both sandbox and production accounts:

  • serverURL: This is always https://api.signicat.com/encore/encap.
  • applicationId: To find this, see Details for your MobileID account in the Signicat Dashboard.
  • publicKey: To find this, see Details for your MobileID account in the Signicat Dashboard.