Usage

You can use the included WorkflowController to integrate the online identification function into your own UI.

The WorkflowController communicates asynchronously via callbacks, see section WorkflowController callbacks for a definition of the callbacks and WorkflowController data types for the used data types. You have to first define and register your own callbacks by calling registerCallbacks. After you have registered the callbacks you can call start to initialize the WorkflowController. onStarted is called after the AusweisApp SDK Wrapper is initialized, after which you can either start an authentication (startAuthentication) or a PIN change (startChangePin). To free up system ressources you can call stop after you are finished using the WorkflowController.

The example below shows the minimal worflow to achieve an authentication with a preset PIN. Empty callback declarations are left out to increase readability.

import com.governikus.ausweisapp.sdkwrapper.SDKWrapper.workflowController

internal class WorkflowViewModel(application: Application) : AndroidViewModel(application) {

    [...]

    private val workflowCallbacks = object : WorkflowCallbacks {
       override fun onStarted() {
           workflowController.startAuthentication(
               Uri.parse("[...]"),
               false,
               false
           )
       }

       override fun onAuthenticationCompleted(authResult: AuthResult) {
           val url = authResult?.url ?: return
           val intent = Intent(Intent.ACTION_VIEW, url)
           intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
           getApplication<Application>().applicationContext.startActivity(intent)
       }

       override fun onEnterPin(error: String?, reader: Reader) {
           workflowController.setPin("123456")
       }

       override fun onAccessRights(error: String?, accessRights: AccessRights?) {
           workflowController.accept()
       }

       [...]
   }

   init {
       workflowController.registerCallbacks(workflowCallbacks)
       workflowController.start(application)
   }

   override fun onCleared() {
       super.onCleared()
       workflowController.unregisterCallbacks(workflowCallbacks)
       workflowController.stop()
   }
}

Warning

On Android you have to pass through incoming NFC tags to the WorkflowController, as only the active Activity receives them. See section Passing NFC tags to the WorkflowController on Android for more details.