Usage Overview

Initialize QoreID SDK

In your main activity OnCreate include

QoreIDSdk.initialize(this)

Launch QoreID SDK with QoreIDButton

The QoreIDButton is the entry point into the QoreID SDK.

  1. Include it in your layout file:
<com.qoreid.sdk.core.QoreIDButton
  android:id="@+id/qoreIDButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:text="Verify..." />
  1. Implement in your Activity
overide fun onCreate(saveInstanceState: Bundle?){
  	val qoreIDButton = findViewById(R.id.qoreIDButton)
    qoreIDButton
   		  .params(QoreIDParams)
   		  .registerForResult(ActivityResultLauncher)
}

Clicking the button will launch the QoreID SDK, as long as valid QoreIDParams are provided.

The following key functions on the QoreIDButton are available for use:

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 more details about QoreIDParams).

Launch QoreID SDK via QoreIDSdk Object

overide fun onCreate(saveInstanceState: Bundle?){
  	
  	yourOwnBtn.setOnClickListener {
     		QoreIDSdk.params(qoreIDParams)
        QoreIDSdk.registerForResult(activityResultLauncher)
        QoreIDSdk.launch(this)
    }
}

For more details about the QoreIDButton, click here

Receiving Results from the SDK

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.

// Using ActivityResultLauncher with registerForActivityResult is recommended.
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.
           	}
       }
    }
}

// Alternatively, use onActivityResult() 
@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.
         	    }
         	}
    }
}

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

/* 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.
        }
    }
}