4️⃣ Scan Document
To scan the NFC you need to provide the Basic Access Control - BAC - key. The BAC key is computed from the Machine Readable Zone - MRZ and acts as "proof of authorization" to access the chip content.
The scanDocument
API will compute the bac key from the MRZ and return an EDocument
if the entire flow is successful.
Api Signature
fun scanDocument(onCompletion: (DocumentResult<EDocument>) -> Unit)
Returned result
If the Keyless Document SDK can read the NFC tag it will return an instance of EDocument
containing the data read.
public data class EDocument(
// The path to the image extracted from the document
var facePath: String = UNKNOWN,
// Personal information of the document holder
var personalInformation: PersonalInformation = PersonalInformation(),
// Information about the document itself
var documentInformation: DocumentInformation = DocumentInformation(),
// Security-related information and verification status
var security: DocumentSecurity = DocumentSecurity(),
)
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 class ChipAuthError(val errorMessage: String? = null) : DocumentError(
code = 7002,
message = errorMessage ?: "BAC Authentication failed"
)
public data class ChipException(val e: Throwable?) : DocumentError(
code = 7003,
message = e?.message ?: "Chip exception"
)
public data class ChipLost(val permissionDenial: Boolean = false) : DocumentError(
code = 7004,
message = "Chip lost"
)
public data class UnknownError( override val message: String) : DocumentError(
code = 9999,
message = message
)
Example usage
KeylessDocument.scanDocument() {
when (it) {
is DocumentResult.Success -> {
Log.d(TAG, "EDocument ${it.value}")
}
is DocumentResult.Failure -> {
Log.d(TAG, "Error ${it.error}")
}
}
Last updated
Was this helpful?