iOS SDK Integration
Capturing faces for FaceAuthen with the CAKE eKYC iOS SDK, version 1.1.9. The entry point is CakeEkycSdk.
Build Specifications
| What | Description |
|---|---|
| Xcode | 16.0+ |
| Target iOS version | 13+ |
| Swift | 5 |
Setup Dependencies
Add the SDK frameworks to your target, then declare the camera permission:
xml
<key>NSCameraUsageDescription</key>
<string>Camera access helps us give you a better experience</string>ruby
pod 'TensorFlowLiteSwift', '2.6.0'
pod 'GoogleMLKit/FaceDetection', '6.0.0'
pod 'PromisesSwift', '~> 2.3.1'
pod 'SnapKit', '~> 5.0.1'Initialize
swift
let config = CESConfig.Builder()
.withBaseUrl(url: "<BASE_URL>")
.withToken(tokenProvider: tokenProvider)
.withLanguage(language: .vi)
.withLogger(logger: logger)
.build()
self.cancelable = CakeEkycSdk.getInstance(config: config)
.receive(on: DispatchQueue.main)
.sink { [weak self] ekycSdk in
self?.ekycSdk = ekycSdk
}Capture Faces
swift
class YourUIViewController: UIViewController, CESFaceCapturingDelegate {
func onSuccess(result: CESSelfieResult) {}
func onError(error: CESError) {}
func onEvent(event: CESEkycEvent) {}
private func startFace() {
guard let ekycSdk else { return }
let config = CESTakeFaceConfig(captureOnly: false, loadingView: loadingView)
ekycSdk.takeFaces(hostViewController: self, config: config, delegate: self)
}
}CESSelfieResult carries the captured faces plus the check results.
| Field | Type | Description |
|---|---|---|
faces | [Face]? | Captured faces, each with image and gesture. |
sanityResult | [CESEkycResponse<CESFaceSanityData>]? | Sanity response per image. |
livenessResult | CESEkycResponse<CESFaceLivenessData>? | Liveness result. |
Take face.image.id from each entry and pass those as the faces array to Register Faces or Verify Face Authen.
Errors
| Field | Type | Description |
|---|---|---|
CESError.userCancelled | 40001 | User pressed back. |
CESError.timeoutError | 40000 | Timeout. |
CESError.permissionNotGranted | 40002 | Permissions were not granted. |
CESError.qualityFailed | 60002 / 60003 | kErrorCodeFaceSanityFailed or kErrorCodeFaceLivenessFailed. |
CESError.unexpectedError | 50000 | Runtime exception. |
INFO
iOS has no camera-specific error code. 40003 exists only on Android and Flutter — camera failures on iOS surface as unexpectedError.
Upload Image
swift
let uploadResult = ekycSdk.upload(image: image, label: "portrait", metaData: metaData)
switch uploadResult {
case .success(data: let uploadResponse):
debugPrint("success: \(uploadResponse.data?.imageId)")
case .fail(error: let error):
debugPrint("fail: \(error)")
default: fatalError()
}Data is also accepted: ekycSdk.upload(data: data, label: "portrait", metaData: metaData).
Individual Checks
swift
let faceSanity = ekycSdk.checkFaceSanity(params: CESFaceSanityParams(image: "<IMAGE_ID>"))
let faceLiveness = ekycSdk.checkFaceLiveness(params: CESFaceLivenessParams(images: ["<IMAGE_ID>"]))
let compared = ekycSdk.compareFaces(params: CESFaceCompareParams(image1: "<IMAGE_ID_1>", image2: "<IMAGE_ID_2>"))INFO
CESFaceLivenessParams takes images: [String] — pass an array, not a single image.
Next Steps
- Mobile SDK Overview — concepts shared across platforms
- Register Faces — enrol the captured image IDs
- Verify Face Authen — authenticate with a fresh capture