2️⃣ Read MRZ
The Machine Readable Zone - MRZ contains the information that acts as "proof of authorization" to access the chip content. If machine-reading of the MRZ is not possible the information can be entered manually.
Api Signature
fun readMRZ(onCompletion: (DocumentResult<MRZDocument>) -> Unit)
Returned result
If the Keyless Document SDK can read the MRZ it will return an instance of MRZDocument
containing the data read.
data class MRZDocument(
val documentNumber: String,
val dateOfBirth: String,//Format as yy-MM-dd
val dateOfExpiration: String,//Format as yy-MM-dd
val personalNumber: String? = null,
val firstName: String? = null,
val lastName: String? = null,
val nationality: String? = null,
val issuingState: String? = null,
val documentType: String? = null,
var gender: String? = null
)
Errors
In case of errors the Keyless Document SDK will return the following errors:
public sealed class DocumentError(
public open val code: Int,
public open val message: String,
)
// errors launching the MrzCameraActivity
public data class InternalError(override val code: Int) : DocumentError(code, "Internal error")
public data object UserCancelled : DocumentError(
code = 5000,
message = "User cancelled the operation."
)
public data object LauncherNotInitialized : DocumentError(
code = 5002,
message = "Launcher is null or not initialized"
)
public data object PermissionDenied : DocumentError(
code = 7001,
message = "Permission denied."
)
public data class UnknownError( override val message: String) : DocumentError(
code = 9999,
message = message
)
Example usage
KeylessDocument.readMRZ {
when (it) {
is DocumentResult.Success -> {
Log.d(TAG, "MRZ data ${it.value}")
}
is DocumentResult.Failure -> {
Log.d(TAG, "MRZ error ${it.error}")
}
}
Last updated
Was this helpful?