Skip to main content

Identity SDK for Android

This guide explains how to integrate the Identity SDK into your Android project.

info

You can find a sample project demonstrating the integration here.

Prerequisites

  • S3 Credentials: Make sure you are provided with the required credentials S3_BUCKET_ID, S3_ACCESS_KEY, and S3_SECRET_KEY.

1. Project Setup

a. Add local.properties

Create or update your local.properties file in the root of your project to include S3 credentials:

PKB_S3_BUCKET_ID=your_bucket_id
PKB_S3_ACCESS_KEY=your_access_key
PKB_S3_SECRET_KEY=your_secret_key

b. Configure Maven Repositories

Add the following Maven configurations in your app's app/build.gradle file:

app/build.gradle
// configure localProperties
def localPropertiesFile = rootProject.file("local.properties")
def localProperties = new Properties().load(new FileInputStream(localPropertiesFile))

android {
...
repositories {
...
maven {
url 's3://' + localProperties.getProperty('PKB_S3_BUCKET_ID')
credentials(AwsCredentials) {
accessKey localProperties.getProperty('PKB_S3_ACCESS_KEY')
secretKey localProperties.getProperty('PKB_S3_SECRET_KEY')
}
}
}
}

2. Additional Configurations

a. Packaging Options

Add the following configurations in your app's app/build.gradle file:

app/build.gradle
android {
...
packagingOptions {
...
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}

b. ProGuard Rules

proguard-rules.pro
-keep class ai.onnxruntime.** { *; }

3. Add Dependency

Add the following dependency in app/build.gradle:

app/build.gradle
dependencies {
...
implementation ('com.peekaboo.connect.identity:sdk:<latest-version>') {
exclude group: "com.android.support", module: "appcompat-v7"
exclude group: "com.android.support", module: "support-vector-drawable"
exclude group: "com.android.support", module: "support-annotations"
}
}

Make sure to add the latest provided version of the module.

Integration along with Peekaboo Connect SDK

If you are integrating the Identity SDK along with the Peekaboo Connect SDK, exclude the camera library from all PKB-Connect modules.

app/build.gradle
  implementation ('com.peekaboo.connect.deals:sdk:<latest-version>') {
exclude group: "com.peekaboo.connect.dependencies", module:"react-native-vision-camera"
}
}

4. Initialize SDK

a. Initializing ActivityResultLauncher

ActivityResultLaunchers are used to handle the results from the launched activities. Define these as global variables and initialize them in the onCreate method.

MainActivity.kt
private lateinit var identityActivityLauncher: ActivityResultLauncher<Intent>

Initialization in onCreate:

MainActivity.kt
identityActivityLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val data = result.data
data?.let {
// Do anything with the results
Log.d("IdentityActivityResult", "Received data: $data")
}
}
}

b. Launching Identity Activity

Make an Intent

MainActivity.kt
val intent = Intent(this, com.peekaboo.connect.identity.MainActivity::class.java)

Add Initial Properties

MainActivity.kt
val bundle = Bundle().apply {
// Add Font
putInt("font", R.font.poppins)
// Other Configurations
}
intent.putExtras(bundle)

Launch Identity Activity

MainActivity.kt
identityActivityLauncher.launch(intent)