QoreID Android SDK

This guide provides information on how to integrate the QoreID SDK with your Android application. With the QoreID SDK, you can more conveniently access QoreID services.

📘

Note

With this release, customers can perform digital address verification via Verifind. Other QoreID services will be available in future releases.

Requirements

  • Android OS version: v5 (API v21) or higher.
  • minSdk: 21
  • targetSdkVersion: 33
  • Kotlin: 1.5.21 or higher.

Installation

In your project-level build.gradle file

Add mavenCentral() as a repository

buildscript {
   repositories {
     ...
     mavenCentral()
   }
}

In your app module's build.gradle file

Add the QoreID SDK as a Gradle dependency:

dependencies {
  implementation 'com.qoreid:qoreid-sdk:1.0.0-beta'
}

Add Java 8 support:

android { 
    // ...
    compileOptions {   
        sourceCompatibility JavaVersion.VERSION_1_8 
        targetCompatibility JavaVersion.VERSION_1_8 
    } 

    // For kotlin codebases, include
    kotlinOptions {
         jvmTarget = "1.8" 
    }
}

Usage Overview

QoreIDButton

Use the QoreIDButton view to launch the QoreID SDK from your application. Include it in your layout file:

<com.qoreid.sdk.views.QoreIDButton
  android:id="@+id/qoreIDButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:text="Verify Address" />

And implement in your Activity (or Fragment)

overide fun onCreate(saveInstanceState: Bundle?){
    ....
    val qoreIDButton = findViewById(R.id.qoreIDButton)
    qoreIDButton
      .params(QoreIDParams)
      .launchVerifind()
      .registerForResult(ActivityResultLauncher)
}

The following methods on the QoreIDButton are provided for use in launching the SDK:

MethodArgumentsDescription
registerForResult(...)ActivityResultLauncherThis is how the SDK will return results to your app. Either call this or implement onActivityResult(...) in your Activity.
params(...)QoreIDParamsThis is where you pass data for the SDK to function. See the QoreIDParams section for more details
launchVerifind()Call this to indicate that you want to carry out Digital Address Verification with Verifind

Verifind Usage Example

Optionally provide details about the applicant and address data. If not provided, the user will be prompted to enter the values in a form.

val qoreIDParams = QoreIDParams.Builder()
             .clientId(clientId)
             .applicantData(applicantData)
             .addressData(addressData)
             .build()

qoreIdButton
  .params(qoreIDParams)
  .registerForResult(activityResultLauncher)
  .launchVerifind()
QoreIDParams qoreIDParams = new QoreIDParams.Builder()
             .clientId(clientId)
             .applicantData(applicantData)
             .addressData(addressData)
             .build()

qoreIdButton
  .params(qoreIDParams)
  .registerForResult(activityResultLauncher)
  .launchVerifind()

Other QoreId Usage Example

Optionally provide details about the identity data and applicant data. If not provided, the user will be prompted to enter the values in a form.

val qoreIDParams = QoreIDParams.Builder()
             .clientId(clientId)
             .applicantData(applicantData)
             .addressData(addressData)
             .build()

qoreIdButton
  .params(qoreIDParams)
  .forService(productCode) 
  .registerForResult(activityResultLauncher)
params(...)QoreIDParamsThis is where you pass data for the SDK to function. See the QoreIDParams section for more details
'forService(productCode)'StringProductCode determines the kind of product/service to be launched. See the ProductCode section for more details

### Receiving Results Back

The QoreID SDK returns results either via an ActivityResultLauncher that you provide; or via an onActivityResult(...) implementation in your Activity. The ActivityResultLauncher approach is recommended. If you choose to implement onActivityResult(...), use the QORE_ID_RESULT_CODE constant as the result code.

/** ActivityResultLauncher using registerForActivityResult */
private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
    if (it.resultCode == QORE_ID_RESULT_CODE && it.data != null) {
        val qoreIdResult =  data.getSerializableExtra(QORE_ID_RESULT_EXTRA_KEY) as QoreIDResult
​
        when (qoreIdResult) {
            is ErrorResult -> { 
                            // Handle error.
            }
            is SuccessResult -> { 
                            // Handle success.
            }
       }
​
    }
}

overide fun onCreate(saveInstanceState: Bundle?){
    ...
    qoreIdButton
      .registerForActivityResult(activityResultLauncher);
}

/** Use only if registerForActivityResult was not used by qoreIdButton **/
@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (resultCode == QORE_ID_RESULT_CODE && data != null) {
            val qoreIdResult =  data.getSerializableExtra(QORE_ID_RESULT_EXTRA_KEY) as QoreIDResult?

            when (qoreIdResult) {
                is ErrorResult -> { 
                                // Handle error.
                }
                is SuccessResult -> {
                                // Handle success.
                }
            }
    }
}
/* ActivityResultLauncher */

private final ActivityResultLauncher<Intent> activityResultLauncher = activity.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),  new ActivityResultCallback<ActivityResult>(){
    @Override
    public void onActivityResult(ActivityResult result) {
        if (result.getResultCode() == QORE_ID_RESULT_CODE && result.getData() != null) {
            QoreIDResult qoreIdResult = (QoreIDResult) result.getData().getSerializableExtra(QORE_ID_RESULT_EXTRA_KEY);
          
            if (qoreIdResult instanceof ErrorResult){
                // Handle error.
            } else if (qoreIdResult instanceof SuccessResult){
                // Handle Success.
            }
        }
    }
});


@Override
protected void onCreate(saveInstanceState: Bundle?){
    ...
    qoreIdButton
      .registerForActivityResult(activityResultLauncher);
}


/**Use only if registerForActivityResult was not used in the paramsBuilder.build(),**/
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == QORE_ID_RESULT_CODE && data != null) {
        QoreIDResult qoreIdResult = (QoreIDResult) result.getData().getSerializableExtra(QORE_ID_RESULT_EXTRA_KEY);

        if (qoreIdResult instanceof ErrorResult){
            // Handle error.
        } else if (qoreIdResult instanceof SuccessResult){
            // Handle Success.
        }
    }
}

Proguard Configuration

Add the line below to your proguard rules file

-keep class com.qoreid.sdk.** { *; }