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 de.governikus.ausweisapp2.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()
}
}
import AusweisApp2SDKWrapper
@available(iOS 13, *)
class WorkflowViewModel: ObservableObject {
private let workflowController = AA2SDKWrapper.workflowController
init() {
AA2SDKWrapper.workflowController.registerCallbacks(self)
AA2SDKWrapper.workflowController.start()
}
private func cleanup() {
AA2SDKWrapper.workflowController.unregisterCallbacks(self)
if AA2SDKWrapper.workflowController.isStarted {
AA2SDKWrapper.workflowController.stop()
}
}
}
@available(iOS 13, *)
extension WorkflowViewModel: WorkflowCallbacks {
func onAccessRights(error: String?, accessRights: AusweisApp2SDKWrapper.AccessRights?) {
workflowController.accept()
}
func onAuthenticationCompleted(authResult: AusweisApp2SDKWrapper.AuthResult) {
if let url = authResult.url {
UIApplication.shared.open(url)
}
}
func onEnterPin(error: String?, reader: AusweisApp2SDKWrapper.Reader) {
workflowController.setPin("123456")
}
func onStarted() {
let tcTokenUrl = URL(string: "[...]")
workflowController.startAuthentication(withTcTokenUrl: tcTokenUrl)
}
func start() {
workflowController.registerCallbacks(self)
workflowController.start()
}
}
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.
- WorkflowController API
- WorkflowController callbacks
- onStarted
- onAuthenticationStarted
- onAuthenticationStartFailed
- onChangePinStarted
- onAccessRights
- onCertificate
- onInsertCard
- onPause
- onReader
- onReaderList
- onEnterPin
- onEnterNewPin
- onEnterPuk
- onEnterCan
- onAuthenticationCompleted
- onChangePinCompleted
- onStatus
- onInfo
- onWrapperError
- onBadState
- onInternalError
- WorkflowController data types
- Passing NFC tags to the WorkflowController on Android