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
| Field | Type | Description |
|---|---|---|
upload(image:label:metaData:) | CESResult<CESEkycResponse<CESPhotoUploadData>> | Uploads a UIImage. |
upload(data:label:metaData:) | CESResult<CESEkycResponse<CESPhotoUploadData>> | Uploads raw Data. |
takeNid(hostViewController:config:delegate:) | Void | Captures 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:) | Void | Captures 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() | Void | Terminates ongoing NID and face capturing tasks. |
getInstance(config:) | static Future<CakeEkycSdk, Never> | Creates an instance asynchronously. |
Results
CESNidCardResult
| Field | Type | Description |
|---|---|---|
cardType | CESCardType | The type of NID card (CCCD). |
frontSideImage | CESEkycImage? | The front side of the card. |
backSideImage | CESEkycImage? | The back side of the card. |
qrData | QRData? | NID QR code data. |
sanityResult | CESEkycResponse<CESNidSanityData>? | Sanity check result. |
tamperingResult | CESEkycResponse<CESNidTamperingData>? | Tampering check result. |
cardInfo | CESEkycResponse<CESNidReadInfoData>? | Extracted card details. |
CESNidCardResult.QRData
| Field | Type | Description |
|---|---|---|
raw | String? | String value from the QR scan. |
image | CESEkycImage? | QR code image. |
CESSelfieResult
| Field | Type | Description |
|---|---|---|
faces | [Face]? | Captured faces. |
sanityResult | [CESEkycResponse<CESFaceSanityData>]? | Sanity response per face image. |
livenessResult | CESEkycResponse<CESFaceLivenessData>? | Liveness check result. |
CESSelfieResult.Face
| Field | Type | Description |
|---|---|---|
image | CESEkycImage? | The portrait image. |
gesture | String | Face gesture: frontal, left, right, up, down. |
Configuration
CESConfig
| Field | Type | Description |
|---|---|---|
languageCode | String | vi or en. |
baseUrl | String | Base URL for network requests. |
tokenProvider | TokenProvider? | Authentication token provider. |
logger | Logger? | Log sink. |
Config.Builder
| Field | Type | Description |
|---|---|---|
withLanguage(language:) | Builder | Sets the language code. |
withBaseUrl(url:) | Builder | Sets the base URL. |
withToken(tokenProvider:) | Builder | Sets the token provider. |
withLogger(logger:) | Builder | Sets the logger. |
build() | Config | Creates the CESConfig. |
TokenProvider
| Field | Type | Description |
|---|---|---|
getToken(timestamp:path:method:) | String | Returns an authentication token for the given request. |
Logger
| Field | Type | Description |
|---|---|---|
info(log:) | Void | Logs an informational message. |
error(log:) | Void | Logs an error message. |
warning(log:) | Void | Logs a warning message. |
CESTakeNidConfig
| Field | Type | Description |
|---|---|---|
cardType | CESCardType | Card type, defaults to .cccd. |
cardSides | [CESCardSide] | Sides to capture, defaults to [.front, .back]. |
requiredReview | Bool | Require review, defaults to true. |
autoCaptureEnable | Bool | Auto-capture once quality passes, defaults to true. |
requiredScanQR | Bool | Require QR scanning, defaults to false. |
captureOnly | Bool | Capture-only mode, defaults to false. |
loadingView | UIView? | Custom loading UI. |
otherSideImages | [CESCardSide: CESEkycImage] | The already-captured other side. |
CESTakeFaceConfig
| Field | Type | Description |
|---|---|---|
captureOnly | Bool | Capture-only mode, defaults to false. |
loadingView | UIView? | Custom loading UI. |
Request Params
| Field | Type | Description |
|---|---|---|
CESCheckNidSanityParams | struct | image, image2?, cardType, specialTypeId? |
CESCheckNidTamperingParams | struct | image, image2?, cardType, level? |
CESNidReadInfoParams | struct | image, image2?, cardType |
CESFaceSanityParams | struct | image — face image id |
CESFaceLivenessParams | struct | images — array of face image ids |
CESFaceCompareParams | struct | image1, image2 |
Data Types
CESEkycImage
| Field | Type | Description |
|---|---|---|
id | String? | Unique identifier after uploading. |
label | String? | Label describing the image. |
image | UIImage? | The image data. |
CESEkycResponse
| Field | Type | Description |
|---|---|---|
data | T? | The response data. |
errors | [CESResponseError]? | Error details. |
code | Int? | Response status code. |
message | String? | Response message. |
signature | String? | Response signature. |
signatureTimestamp | String? | Signature timestamp. |
rawData | String? | Raw data string. |
request | String? | The request. |
responseBody | String? | Raw response body. |
CESResponseError
| Field | Type | Description |
|---|---|---|
code | String? | Error code. |
message | String? | Error description. |
CESCardType
| Field | Type | Description |
|---|---|---|
id | String | Card type identifier, e.g. vn.national_id. |
name | String | Card type name, e.g. id_card.vn.national_id. |
cccd | static CESCardType | Vietnamese National ID. |
CESCardSide
public enum CardSide: String — values front and back.
CESNidSanityData
| Field | Type | Description |
|---|---|---|
status | String? | success or failure. |
cardSanity | CESCardSanity? | Card sanity details. |
image1 | CESNidResponseImage? | First NID image. |
image2 | CESNidResponseImage? | Second NID image. |
requestId | String? | Request identifier. |
CESCardSanity
| Field | Type | Description |
|---|---|---|
verdict | String? | good when the check passed. See Verdict Definitions. |
score | Double? | Confidence score. |
info | String? | Additional information. |
CESNidResponseImage
| Field | Type | Description |
|---|---|---|
id | String? | Image identifier. |
transformedImageId | String? | Transformed image identifier. |
cardBox | CardBox? | Card bounding box. |
CESNidTamperingData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the tampering check. |
cardTampering | CESCardTampering? | Tampering details. |
requestId | String? | Request identifier. |
imageId imageId2 | String? | Images used. |
CESCardTampering / CESCardTemperingDetail
| Field | Type | Description |
|---|---|---|
verdict | String? | good when the check passed, otherwise the specific signal. |
score | Double? | Confidence score. |
details | [CESCardTamperingDetail]? | Individual tampering signals. |
info | String? | Additional information. Detail only. |
CESNidReadInfoData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the extraction. |
image | CESReadNidImageData? | Data from the first image. |
image2 | CESReadNidImageData? | Data from the second image. |
cardInfo | [CESCardInfo]? | Consolidated card information. |
requestId | String? | Request identifier. |
CESReadNidImageData
| Field | Type | Description |
|---|---|---|
id | String? | NID image identifier. |
transformedImageId | String? | Transformed image identifier. |
cardBox | CardBox? | Card bounding box. |
qr | CESNidQRData? | QR code data. |
ocr | CESNidOcrData? | OCR data. |
mrz | CESNidMrzData? | MRZ data. |
CESNidQRData / CESNidOcrData / CESNidMrzData
| Field | Type | Description |
|---|---|---|
parsedFields | [CESParsedField]? | Parsed fields from this source. |
raw | String? | Raw value. QR only. |
confidenceScore | Double? | Confidence in the extraction. |
CESParsedField / CESCardInfo
| Field | Type | Description |
|---|---|---|
field | String? | Field name. |
value | String? | Field value. |
confidenceVerdict | String? | Confidence verdict. |
confidenceScore / confidentScore | Double? | Confidence score. |
Note the iOS types use field where the Android and Flutter equivalents use key.
CardBox / Point
| Field | Type | Description |
|---|---|---|
topLeft topRight bottomLeft bottomRight | Point? | Corners of the card box. |
x y | Double? | Point coordinates. |
CESFaceSanityData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the face sanity check. |
portraitSanity | CESPortraitSanity? | Sanity details. |
requestId | String? | Request identifier. |
image | CESPortraitImageInfo? | Portrait image information. |
isSanityPassed() | Bool | True when the verdict is good. |
CESPortraitSanity
| Field | Type | Description |
|---|---|---|
verdict | String? | Outcome of the sanity check. |
score | Double? | Confidence score. |
CESFaceLivenessData / CESLivenessResult
| Field | Type | Description |
|---|---|---|
status | String? | Status of the liveness check. |
isLive | Bool? | Whether the face is live. |
score | Double? | Confidence score. |
results | [CESLivenessResult]? | Per-image results. |
requestId | String? | Request identifier. |
mainImageId | String? | Main image used. |
id | String? | Image identifier. Result only. |
CESFaceCompareData / CESFaceCompare
| Field | Type | Description |
|---|---|---|
status | String? | Status of the comparison. |
faceCompare | [CESFaceCompare]? | Comparison results. |
face1Id face2Id | String? | The compared face image ids. |
score | Double? | Similarity score. |
result | String? | matched or not matched. |
Delegates and Events
CESNidCapturingDelegate / CESFaceCapturingDelegate
| Field | Type | Description |
|---|---|---|
onEvent(event:) | Void | An event occurred during capture. |
onError(error:) | Void | An error occurred. |
onSuccess(result:) | Void | Capture succeeded. |
CESEkycEvent
| Field | Type | Description |
|---|---|---|
id | Int | Event identifier. |
params | [String: Any] | Event parameters. |
timestamp | Double | Creation time in milliseconds. |
timeoutEvent | -1000 | A timeout occurred. |
faceSelfieAssessingResultEvent | -1001 | Face selfie assessment result. |
nidAssessingResultEvent | -1003 | NID assessment result. |
faceSelfieResultEvent | -1004 | Selfie result. |
nidCaptureStartedEvent | -1008 | NID capture started. |
nidCaptureEndedEvent | -1009 | NID capture ended. |
nidReviewStartedEvent | -1010 | NID review started. |
nidShuttleClickedEvent | -1011 | Shutter clicked. |
nidAutoCaptureSelectedEvent | -1012 | Auto-capture selected. |
nidReviewEndedEvent | -1013 | NID review finished. |
nidReviewAcceptClickedEvent | -1014 | Accept clicked. |
nidReviewDenyClickedEvent | -1015 | Deny clicked. |
faceCaptureStartedEvent | -1016 | Face capture started. |
faceCaptureEndedEvent | -1017 | Face capture ended. |
backClickedEvent | -1018 | In-screen back button clicked. |
kCardType | card_type | Param key for card type. |
kCardSide | card_side | Param key for card side. |
kAssessingCode | assessing_code | Param key for assessment code. |
kAssessingMessage | assessing_message | Param key for assessment message. |
kAutoCapture | auto_capture | Param key for auto-capture. |
kStepName | step_name | Param key for step name. |
kSelfieImages | selfie_images | Param key for selfie images. |
CESError
public enum CESError: Error
| Field | Type | Description |
|---|---|---|
kErrorCodeTimeout | 40000 | Timeout. |
kErrorCodeCancelled | 40001 | User cancellation. |
kErrorCodePermissionNotGranted | 40002 | Permission denial. |
kErrorCodeUnexpected | 50000 | Unexpected error. |
kErrorCodeNidSanityFailed | 60000 | NID sanity failure. |
kErrorCodeNidTamperingFailed | 60001 | NID tampering failure. |
kErrorCodeFaceSanityFailed | 60002 | Face sanity failure. |
kErrorCodeFaceLivenessFailed | 60003 | Face liveness failure. |
Cases: timeoutError, userCancelled, permissionNotGranted, unexpectedError(_ cause:), QualityFailed(code:detail:message:).
Next Steps
- iOS SDK Integration — the integration guide
- Mobile SDK Overview — concepts shared across platforms