Skip to content

iOS SDK Reference ​

Every public class, struct and method in the eKYC iOS SDK. All types are prefixed CES. See iOS SDK Integration for the integration guide.

CakeEkycSdk ​

public class CakeEkycSdk

FieldTypeDescription
upload(image:label:metaData:)CESResult<CESEkycResponse<CESPhotoUploadData>>Uploads a UIImage.
upload(data:label:metaData:)CESResult<CESEkycResponse<CESPhotoUploadData>>Uploads raw Data.
takeNid(hostViewController:config:delegate:)VoidCaptures NID → uploads → checks sanity → checks tampering → extracts info. Delivers CESNidCardResult via the delegate.
checkNidSanity(params:)CESResult<CESEkycResponse<CESNidSanityData>>Checks the sanity of NID images.
checkNidTampering(params:)CESResult<CESEkycResponse<CESNidTamperingData>>Checks for tampering in NID images.
readNidInfo(params:)CESResult<CESEkycResponse<CESNidReadInfoData>>Extracts information from NID images.
takeFaces(hostViewController:config:delegate:)VoidCaptures faces → uploads → checks sanity → checks liveness. Delivers CESSelfieResult.
checkFaceSanity(params:)CESResult<CESEkycResponse<CESFaceSanityData>>Checks the sanity of a face image.
checkFaceLiveness(params:)CESResult<CESEkycResponse<CESFaceLivenessData>>Checks liveness of face images.
compareFaces(params:)CESResult<CESEkycResponse<CESFaceCompareData>>Compares two face images.
close()VoidTerminates ongoing NID and face capturing tasks.
getInstance(config:)static Future<CakeEkycSdk, Never>Creates an instance asynchronously.

Results ​

CESNidCardResult ​

FieldTypeDescription
cardTypeCESCardTypeThe type of NID card (CCCD).
frontSideImageCESEkycImage?The front side of the card.
backSideImageCESEkycImage?The back side of the card.
qrDataQRData?NID QR code data.
sanityResultCESEkycResponse<CESNidSanityData>?Sanity check result.
tamperingResultCESEkycResponse<CESNidTamperingData>?Tampering check result.
cardInfoCESEkycResponse<CESNidReadInfoData>?Extracted card details.

CESNidCardResult.QRData ​

FieldTypeDescription
rawString?String value from the QR scan.
imageCESEkycImage?QR code image.

CESSelfieResult ​

FieldTypeDescription
faces[Face]?Captured faces.
sanityResult[CESEkycResponse<CESFaceSanityData>]?Sanity response per face image.
livenessResultCESEkycResponse<CESFaceLivenessData>?Liveness check result.

CESSelfieResult.Face ​

FieldTypeDescription
imageCESEkycImage?The portrait image.
gestureStringFace gesture: frontal, left, right, up, down.

Configuration ​

CESConfig ​

FieldTypeDescription
languageCodeStringvi or en.
baseUrlStringBase URL for network requests.
tokenProviderTokenProvider?Authentication token provider.
loggerLogger?Log sink.

Config.Builder ​

FieldTypeDescription
withLanguage(language:)BuilderSets the language code.
withBaseUrl(url:)BuilderSets the base URL.
withToken(tokenProvider:)BuilderSets the token provider.
withLogger(logger:)BuilderSets the logger.
build()ConfigCreates the CESConfig.

TokenProvider ​

FieldTypeDescription
getToken(timestamp:path:method:)StringReturns an authentication token for the given request.

Logger ​

FieldTypeDescription
info(log:)VoidLogs an informational message.
error(log:)VoidLogs an error message.
warning(log:)VoidLogs a warning message.

CESTakeNidConfig ​

FieldTypeDescription
cardTypeCESCardTypeCard type, defaults to .cccd.
cardSides[CESCardSide]Sides to capture, defaults to [.front, .back].
requiredReviewBoolRequire review, defaults to true.
autoCaptureEnableBoolAuto-capture once quality passes, defaults to true.
requiredScanQRBoolRequire QR scanning, defaults to false.
captureOnlyBoolCapture-only mode, defaults to false.
loadingViewUIView?Custom loading UI.
otherSideImages[CESCardSide: CESEkycImage]The already-captured other side.

CESTakeFaceConfig ​

FieldTypeDescription
captureOnlyBoolCapture-only mode, defaults to false.
loadingViewUIView?Custom loading UI.

Request Params ​

FieldTypeDescription
CESCheckNidSanityParamsstructimage, image2?, cardType, specialTypeId?
CESCheckNidTamperingParamsstructimage, image2?, cardType, level?
CESNidReadInfoParamsstructimage, image2?, cardType
CESFaceSanityParamsstructimage — face image id
CESFaceLivenessParamsstructimages — array of face image ids
CESFaceCompareParamsstructimage1, image2

Data Types ​

CESEkycImage ​

FieldTypeDescription
idString?Unique identifier after uploading.
labelString?Label describing the image.
imageUIImage?The image data.

CESEkycResponse ​

FieldTypeDescription
dataT?The response data.
errors[CESResponseError]?Error details.
codeInt?Response status code.
messageString?Response message.
signatureString?Response signature.
signatureTimestampString?Signature timestamp.
rawDataString?Raw data string.
requestString?The request.
responseBodyString?Raw response body.

CESResponseError ​

FieldTypeDescription
codeString?Error code.
messageString?Error description.

CESCardType ​

FieldTypeDescription
idStringCard type identifier, e.g. vn.national_id.
nameStringCard type name, e.g. id_card.vn.national_id.
cccdstatic CESCardTypeVietnamese National ID.

CESCardSide ​

public enum CardSide: String — values front and back.

CESNidSanityData ​

FieldTypeDescription
statusString?success or failure.
cardSanityCESCardSanity?Card sanity details.
image1CESNidResponseImage?First NID image.
image2CESNidResponseImage?Second NID image.
requestIdString?Request identifier.

CESCardSanity ​

FieldTypeDescription
verdictString?good when the check passed. See Verdict Definitions.
scoreDouble?Confidence score.
infoString?Additional information.

CESNidResponseImage ​

FieldTypeDescription
idString?Image identifier.
transformedImageIdString?Transformed image identifier.
cardBoxCardBox?Card bounding box.

CESNidTamperingData ​

FieldTypeDescription
statusString?Status of the tampering check.
cardTamperingCESCardTampering?Tampering details.
requestIdString?Request identifier.
imageId imageId2String?Images used.

CESCardTampering / CESCardTemperingDetail ​

FieldTypeDescription
verdictString?good when the check passed, otherwise the specific signal.
scoreDouble?Confidence score.
details[CESCardTamperingDetail]?Individual tampering signals.
infoString?Additional information. Detail only.

CESNidReadInfoData ​

FieldTypeDescription
statusString?Status of the extraction.
imageCESReadNidImageData?Data from the first image.
image2CESReadNidImageData?Data from the second image.
cardInfo[CESCardInfo]?Consolidated card information.
requestIdString?Request identifier.

CESReadNidImageData ​

FieldTypeDescription
idString?NID image identifier.
transformedImageIdString?Transformed image identifier.
cardBoxCardBox?Card bounding box.
qrCESNidQRData?QR code data.
ocrCESNidOcrData?OCR data.
mrzCESNidMrzData?MRZ data.

CESNidQRData / CESNidOcrData / CESNidMrzData ​

FieldTypeDescription
parsedFields[CESParsedField]?Parsed fields from this source.
rawString?Raw value. QR only.
confidenceScoreDouble?Confidence in the extraction.

CESParsedField / CESCardInfo ​

FieldTypeDescription
fieldString?Field name.
valueString?Field value.
confidenceVerdictString?Confidence verdict.
confidenceScore / confidentScoreDouble?Confidence score.

Note the iOS types use field where the Android and Flutter equivalents use key.

CardBox / Point ​

FieldTypeDescription
topLeft topRight bottomLeft bottomRightPoint?Corners of the card box.
x yDouble?Point coordinates.

CESFaceSanityData ​

FieldTypeDescription
statusString?Status of the face sanity check.
portraitSanityCESPortraitSanity?Sanity details.
requestIdString?Request identifier.
imageCESPortraitImageInfo?Portrait image information.
isSanityPassed()BoolTrue when the verdict is good.

CESPortraitSanity ​

FieldTypeDescription
verdictString?Outcome of the sanity check.
scoreDouble?Confidence score.

CESFaceLivenessData / CESLivenessResult ​

FieldTypeDescription
statusString?Status of the liveness check.
isLiveBool?Whether the face is live.
scoreDouble?Confidence score.
results[CESLivenessResult]?Per-image results.
requestIdString?Request identifier.
mainImageIdString?Main image used.
idString?Image identifier. Result only.

CESFaceCompareData / CESFaceCompare ​

FieldTypeDescription
statusString?Status of the comparison.
faceCompare[CESFaceCompare]?Comparison results.
face1Id face2IdString?The compared face image ids.
scoreDouble?Similarity score.
resultString?matched or not matched.

Delegates and Events ​

CESNidCapturingDelegate / CESFaceCapturingDelegate ​

FieldTypeDescription
onEvent(event:)VoidAn event occurred during capture.
onError(error:)VoidAn error occurred.
onSuccess(result:)VoidCapture succeeded.

CESEkycEvent ​

FieldTypeDescription
idIntEvent identifier.
params[String: Any]Event parameters.
timestampDoubleCreation time in milliseconds.
timeoutEvent-1000A timeout occurred.
faceSelfieAssessingResultEvent-1001Face selfie assessment result.
nidAssessingResultEvent-1003NID assessment result.
faceSelfieResultEvent-1004Selfie result.
nidCaptureStartedEvent-1008NID capture started.
nidCaptureEndedEvent-1009NID capture ended.
nidReviewStartedEvent-1010NID review started.
nidShuttleClickedEvent-1011Shutter clicked.
nidAutoCaptureSelectedEvent-1012Auto-capture selected.
nidReviewEndedEvent-1013NID review finished.
nidReviewAcceptClickedEvent-1014Accept clicked.
nidReviewDenyClickedEvent-1015Deny clicked.
faceCaptureStartedEvent-1016Face capture started.
faceCaptureEndedEvent-1017Face capture ended.
backClickedEvent-1018In-screen back button clicked.
kCardTypecard_typeParam key for card type.
kCardSidecard_sideParam key for card side.
kAssessingCodeassessing_codeParam key for assessment code.
kAssessingMessageassessing_messageParam key for assessment message.
kAutoCaptureauto_captureParam key for auto-capture.
kStepNamestep_nameParam key for step name.
kSelfieImagesselfie_imagesParam key for selfie images.

CESError ​

public enum CESError: Error

FieldTypeDescription
kErrorCodeTimeout40000Timeout.
kErrorCodeCancelled40001User cancellation.
kErrorCodePermissionNotGranted40002Permission denial.
kErrorCodeUnexpected50000Unexpected error.
kErrorCodeNidSanityFailed60000NID sanity failure.
kErrorCodeNidTamperingFailed60001NID tampering failure.
kErrorCodeFaceSanityFailed60002Face sanity failure.
kErrorCodeFaceLivenessFailed60003Face liveness failure.

Cases: timeoutError, userCancelled, permissionNotGranted, unexpectedError(_ cause:), QualityFailed(code:detail:message:).

Next Steps ​

Developers