Skip to content

Android SDK Integration ​

Integration guide for the CICReader Android SDK, version 1.0.6. Written in Kotlin; the entry point is CICReadSDK.

Build Specifications ​

WhatDescription
Kotlin1.7.10
minSdkVersion21

Integration ​

Extract cic-reader-*.zip to a location you can reference — the root project, a local Maven repo, or similar.

groovy
allprojects {
    repositories {
        maven { url "https://maven.google.com" }
        maven { url "https://jcenter.bintray.com" }
        maven { url "path/to/cic_reader" }  // Example: maven { url "${project.rootDir}/repo" }
    }
}
groovy
dependencies {
    implementation("vn.cake.ekyc.sdk:eid:1.x.x")
}

Initialize ​

kotlin
val config = CICConfig(
    "<BASE_URL>",
    true,
    60000,
    60000,
)

CICReadSDK.initialize(
    this,
    config,
    CICHeaderProvider {
        mapOf(
            "custom_header1" to "value1"
        )
    }
)

Parameters:

ParamTypeRequiredDefaultDescription
baseUrlstringYes—Base URL for API calls.
enableCheckNfcDataboolNotrueVerify NFC data against Cake RAR.
readTimeoutintNo60000API read timeout in milliseconds.
writeTimeoutintNo60000API write timeout in milliseconds.
cacheScanStrategyCICCacheScanStrategyNoNO_CACHESee Mobile SDK Overview § Cache on Server Errors.

Read the Chip ​

Using MRZ — 9-digit ID, date of birth, expiry date ​

Throws IllegalMRZException when any input is wrong.

kotlin
class MainActivity : AppCompatActivity(), CICReadCallback {
    fun readCICData() {
        cicReader.readCICData(this,
            "xxxxxxxxx",  // last 9 digits of the NID
            "901212",     // date of birth, yyMMdd
            "301212",     // expiry date, yyMMdd
            "<ACCESS_TOKEN>",
            "ref_00000001",
            this)
    }

    override fun onResult(result: CICReadResult) {
        // Send the result to your backend; never log it — it holds chip data and the verification key.
    }

    override fun onError(exception: CICException?) {
        Log.d("CICReader", exception)
    }

    override fun onCancel() {
        Log.d("CICReader", "on user cancel")
    }
}
ParamTypeRequiredDefaultDescription
activityActivityYes—The current activity.
idCardstringYes—The last 9 digits of the NID number.
dayOfBirthstringYes—Date of birth, format yyMMdd.
expiryDatestringYes—Card expiry date, format yyMMdd.
accessTokenstringYes—Request access token.
refIdstringYes—Transaction reference ID to verify.

Using CAN — 12-digit ID number ​

kotlin
cicReader.readCICData(this,
    "001xxxxxxxxx",  // full 12-digit NID number
    "<ACCESS_TOKEN>",
    "ref_00000001",
    this)
ParamTypeRequiredDefaultDescription
activityActivityYes—The current activity.
idCardstringYes—The full 12-digit NID number.
accessTokenstringYes—Request access token.
refIdstringYes—Transaction reference ID to verify.

Result ​

CICReadResult carries the raw data groups plus, when enableCheckNfcData is true, the parsed citizen fields.

Chip data ​

FieldTypeDescription
comstringUnicode version info and the list of available data groups. Base64.
sodstringThe SOD data from the NFC scan. Base64.
dg1stringIndividual basic details — MRZ information. Base64.
dg2stringCitizen facial image encoding. Base64.
dg13stringCitizen-related information. Base64.
dg14stringUsed for the EAC access mechanism. Base64.
dg15stringPublic key, used for Passive Authentication. Base64.
cloneStatusVerificationStatusClone status of the card. See Mobile SDK Overview § Clone Status.

Citizen fields — API derived ​

FieldTypeDescription
idCardNostringIdentification number of the citizen.
oldIdCardNumberstringOld identification number.
fullNamestringFull name.
dateOfBirthstringDate of birth.
dateOfExpirystringCard expiry date.
genderstringGender.
nationalitystringNationality.
ethnicstringEthnicity.
religionstringReligion.
placeOfOriginstringPlace of origin.
residenceAddressstringPlace of residence.
personalSpecificIdentificationstringPersonal identification characteristics.
dateOfIssuancestringDate the card was issued.
fatherNamestringFather's name.
motherNamestringMother's name.
spouseNamestringPartner's name.
faceImagestringFacial image. Base64.
isVerifiedboolWhether the card was verified by RAR.
verificationKeystringVerification key — pass this to Verify NFC.
requestIdstringRequest ID of the authentication.

Error Handling ​

kotlin
override fun onError(exception: CICException?) {
    Log.w("CICReader", exception)

    when (exception) {
        is CICException.ServerError -> { }
        is CICException.NetworkError -> { }
        // ....
    }
}
FieldTypeDescription
IllegalMRZException600316Illegal MRZ information detected.
IllegalCanException600317Illegal CAN information detected.
EstablishMessageChannelFailedException600333Establishing the PACE message channel failed.
NfcNotAvailableException600032NFC is not available.
UnexpectedException600503An unexpected exception occurred.
ReadingDataFailedException600666Reading data from the NID failed.
NetworkError601400A network error occurred.
ServerError601503A server error occurred.
UnauthorizedError601404The user is unauthorized to access the resource.
NotFoundError601408The requested resource was not found.
ApiError601401An error came back from the API.
InvalidCardType600396The scanned card is not an NID.

Built-in Functions ​

FieldTypeDescription
isNFCAvailable(context)boolWhether NFC reading is available on the device.
isNfcEnable(context)boolWhether NFC is switched on.
openNfcSetting(activity)voidOpens the device NFC settings screen.

Next Steps ​

Developers