Before you start integrating Passbase, we suggest you read first our Overview & Integration Guide on how to integrate Passbase in your system and complete the initial setup steps.
You can either follow the integration guide or watch the integration tutorial that shows the same steps. Please be aware that some property or function names might have slightly changed with newer versions. Make sure to compare your implementation with the latest code snippets here in the documentation.
To install the Passbase Android SDK, add the following to your project’s build.gradle
file:
Please use minSdkVersion
21
in your build.gradle (Module:app)
Add maven {url 'https://button.passbase.com/__android'}
to your repositories part
Finally, add implementation 'com.passbase:passbase_sdk:2.1.1'
to your dependencies.
A complete build.gradle
file should look similar to the example below. Now sync your build.gradle
file to install the SDK.
android {// 1. Ensure you have hat least minSdkVersion 21compileSdkVersion 30defaultConfig {applicationId "com.passbase.passbaseexample"mindSdkVersion 21targetSdkVersion 30versionCode 1versionName "1.0"}}​​repositories {// 2. Add line heremaven { url 'https://button.passbase.com/__android' }}​dependencies {...// 3. Add line hereimplementation 'com.passbase:passbase_sdk:2.1.1'}​
You have successfully installed the Passbase SDK!🎉
Please only use the publishable API key for all integrations. The secret key should never be exposed or used in a web integration or mobile app since it can access to sensitive user data if leaked!
Open your MainActivity in your directory. This was created through the previous step. It will be called something similar to, MainActivity
. Add the two import statements to the top of the file:
import com.passbase.passbase_sdk.PassbaseSDKimport com.passbase.passbase_sdk.PassbaseButton
import com.passbase.passbase_sdk.PassbaseSDK;import com.passbase.passbase_sdk.PassbaseButton;
After that, your need to initialize the SDK with your own publishable API key from your developer dashboard's API settings. See YOUR_PUBLISHABLE_API_KEY
in the coding example below:
package com.passbase.androiddemoapp​import androidx.appcompat.app.AppCompatActivityimport android.os.Bundle​// 1. Add import of Passbase SDK and the Passbase Button to the topimport com.passbase.passbase_sdk.PassbaseSDKimport com.passbase.passbase_sdk.PassbaseButton​class MainActivity : AppCompatActivity() {​override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)​// 2. Initialize object here with own API keyval passbaseRef = PassbaseSDK(this)passbaseRef.initialize("YOUR_PUBLISHABLE_API_KEY")}}​
package com.passbase.androiddemoapp;​import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;​// 1. Add import of Passbase SDK and the Passbase Button to the topimport com.passbase.passbase_sdk.PassbaseSDK;import com.passbase.passbase_sdk.PassbaseButton;​public class MainActivity extends AppCompatActivity {​@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 2. Initialize object here with own API keyPassbaseSDK passbaseRef = new PassbaseSDK(this);passbaseRef.initialize("YOUR_PUBLISHABLE_API_KEY");}}
If you want to prefill a user's email address, to skip the "Approve your Email" screen, you can simply pass the email address into the initialization method.
package com.passbase.androiddemoapp​import androidx.appcompat.app.AppCompatActivityimport android.os.Bundle​// 1. Add import of Passbase SDK and the Passbase Button to the topimport com.passbase.passbase_sdk.PassbaseSDKimport com.passbase.passbase_sdk.PassbaseButton​class MainActivity : AppCompatActivity() {​override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)​val passbaseRef = PassbaseSDK(this)passbaseRef.initialize("YOUR_PUBLISBALE_API_KEY")// 2. You can add the prefill email option here (optional)passbaseRef.prefillUserEmail = "testuser@yourproject.com";}}​
package com.passbase.androiddemoapp;​import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;​// 1. Add import of Passbase SDK and the Passbase Button to the topimport com.passbase.passbase_sdk.Passbase;import com.passbase.passbase_sdk.PassbaseButton;​public class MainActivity extends AppCompatActivity {​@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);​PassbaseSDK passbaseRef = new PassbaseSDK(this);passbaseRef.initialize("YOUR_PUBLISHABLE_API_KEY");// 2. You can add the prefill email option herepassbaseRef.setPrefillUserEmail("testuser@yourproject.com");}}
You have successfully initialized the Passbase SDK in your Android App! 🎉
To start a new verification, you first need to create a verification button. Please ensure that you added both import statements to the top of your file from step 2. You can now do this in two ways:
Keep in mind that in order to successfully finish a verification, you need to pass our liveness detection. Hence, if you develop on a Simulator (e.g. Simulator via Android Studio), you will only see the SDK in UI demo mode. Therefore please use a real device (e.g. an attached Android phone) to fully test and develop with our SDK.
You can create a stylized Passbase button via XML layout like this and give it an id in order to find it later.
<com.passbase.passbase_sdk.PassbaseButtonandroid:id="@+id/passbaseVerificationButton"android:layout_width="250dp"android:layout_height="56dp"android:layout_marginStart="80dp"android:layout_marginTop="336dp"app:backgroundColor="@android:color/white"app:textColor="@android:color/black"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"/>
Or you can create a button programmatically, apply constraints and add it to your view like this.
val verificationButton = PassbaseButton(YOUR_CONTEXT)
PassbaseButton verificationButton = new PassbaseButton(this);
Afterwards a button like this should render in your view.
To start a verification, you can call the startVerification()
method. We suggest doing this with an setOnClickListener
val verificationButton = findViewById<PassbaseButton>(R.id.passbaseVerificationButton)​verificationButton.setOnClickListener {passbaseRef.startVerification()}
PassbaseButton verificationButton = this.findViewById(R.id.passbaseVerificationButton);​verificationButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {passbaseRef.startVerification();}});
PassbaseButton
inherits from LinearLayout
and you can use all the methods that you would usually use for that. Don't forget to add import android.widget.LinearLayout
to the top then.
You have successfully started your first verification. 🎉
In some cases it's useful to know if a user has completed the verification flow or canceled it. For this, you can implement the following delegate/callback methods:
Method | Description |
| This callback method is triggered once a user starts the verification flow. |
| This callback method is triggered once a user completes the full verification flow. You receive an object called |
| This callback method is triggered when a user canceled the verification flow or the verification finished with an error. You can use this to find out if people dropped out of your verification flow. Error codes:
|
We also recommend adding this to your setOnClickListener
method.
val passbaseRef = PassbaseSDK(this)​// Add here the callbackspassbaseRef.callback(object : PassbaseSDKListener {override fun onStart() {println("MainActivity onStart")}​override fun onFinish(identityAccessKey: String?) {println("MainActivity onFinish $identityAccessKey")}​override fun onError(errorCode: String) {println("MainActivity onError $errorCode")}})
PassbaseSDK passbaseRef = new PassbaseSDK(this);​// Add here the callbackspassbaseRef.callback(new PassbaseSDKListener() {@Overridepublic void onStart() {System.out.println("MainActivity onStart");}​@Overridepublic void onFinish(@Nullable String identityAccessKey) {System.out.println("MainActivity onFinish: " + identityAccessKey);}​@Overridepublic void onError(@NotNull String errorCode) {System.out.println("MainActivity onError: " + errorCode);}});​
We recommend the following process for handling identity verifications:
Obtain the authKey
of a successful completed identity verification from the callback method and save it to your db to the user's profile
Set up webhooks to be notified once the identity verification has been processed by our system. Also once you have approved or declined the user in your dashboard
Now you can use your own backend to query the details about this identity verification with e.g. the Get Identity call to obtain the details
Our SDK currently supports a set of customization options which will influence the appearance. To customize the verification flow, please navigate to your developer dashboard's customization section. Here you can choose amongst a variety of colors, fonts, accepted countries & much more.
We also offer a darkmode, which will be automatically triggered if a user has activated this in his system settings.
We support a variety of different languages for the verification flow. As of this writing more than 10 including (English, Spanish, German & many more). If one is missing and you want us to add support for it, please reach out to our customer support.
The SDK automatically detects the language of the user's phone settings. If we support the language, the verification flow will be set to it. Otherwise the default is English.
If you are using ProGuard you might need to add the following options:
-dontwarn okio.**-dontwarn retrofit2.Platform$Java8-dontwarn com.facetec.zoom.sdk.**
to ProGuard exceptions
buildTypes {release {minifyEnabled trueproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}}
A full code example for a basic integration can be found below. You can find a demo integration showing how to integrate the Passbase SDK for Android on our Github page.
​Android Demo App ​
package com.passbase.androiddemoapp​import androidx.appcompat.app.AppCompatActivityimport android.os.Bundleimport com.passbase.passbase_sdk.Passbaseimport com.passbase.passbase_sdk.PassbaseButtonimport android.graphics.Color​class MainActivity : AppCompatActivity() {​override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)​val passbaseRef = PassbaseSDK(this)​// Initialization and prefilled emailpassbaseRef.initialize("YOUR_PUBLISHABLE_API_KEY")passbaseRef.prefillUserEmail = "testuser@yourproject.com";// Handling verifications via callbackspassbaseRef.callback(object : PassbaseSDKListener {override fun onStart() {println("MainActivity onStart")}override fun onFinish(identityAccessKey: String?) {println("MainActivity onFinish $identityAccessKey")}override fun onError(errorCode: String) {println("MainActivity onError $errorCode")}})​val verificationButton = findViewById<PassbaseButton>(R.id.passbaseVerificationButton)verificationButton.setOnClickListener {passbaseRef.startVerification()}}}​
package com.passbase.androiddemoapp;​import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import com.passbase.passbase_sdk.PassbaseSDK;import com.passbase.passbase_sdk.PassbaseButton;import android.graphics.Color;​public class MainActivity extends AppCompatActivity {​@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);​PassbaseSDK passbaseRef = new PassbaseSDK(this);​// Initialization and prefilled emailpassbaseRef.initialize("YOUR_PUBLISHABLE_API_KEY");passbaseRef.setPrefillUserEmail("testuser@yourproject.com");// Handling verifications via callbackspassbaseRef.callback(new PassbaseSDKListener() {@Overridepublic void onStart() {System.out.println("MainActivity onStart");}​@Overridepublic void onFinish(@Nullable String identityAccessKey) {System.out.println("MainActivity onFinish: " + identityAccessKey);}​@Overridepublic void onError(@NotNull String errorCode) {System.out.println("MainActivity onError: " + errorCode);}});PassbaseButton verificationButton = this.findViewById(R.id.passbaseVerificationButton);verificationButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {passbaseRef.startVerification();}});}}​
You have finished the integration of Passbase for Android! 🎉
If you experience that camera is not starting in release build make sure you set enableProguardInReleaseBuilds in build.gradle to false. Or add exeptions as described in ProGuard section above.