Skip to content

Commit

Permalink
fix: config face liveness android
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiankrein committed Oct 26, 2024
1 parent 9e12b30 commit 4964e93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
6 changes: 1 addition & 5 deletions caf-src/android/CafFaceLivenessActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void faceLiveness() throws JSONException {
FaceLivenessConfig config = new FaceLivenessConfig(customConfig);

FaceLiveness faceLiveness = new FaceLiveness.Builder(token)
.setStage(config.cafStage)
.setFilter(config.filter)
.setEnableScreenshots(config.setEnableScreenshots)
.setLoadingScreen(config.setLoadingScreen)
.setFilter(Filter.NATURAL)
.build();

faceLiveness.startSDK(this, personId, new VerifyLivenessListener() {
Expand Down
25 changes: 9 additions & 16 deletions caf-src/ios/CafFaceLiveness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CafFaceLiveness: RCTEventEmitter, FaceLivenessDelegate {
func faceLiveness(token: String, personId: String, config: String) {
var configDictionary: [String: Any]? = nil
var filter = Filter.lineDrawing;
var cafStage = FaceLiveness.CAFStage.PROD
var cafStage = FaceLiveness.CAFStage.prod
var setLoadingScreen:Bool? = nil;

if let data = config.data(using: .utf8) {
Expand All @@ -63,40 +63,32 @@ class CafFaceLiveness: RCTEventEmitter, FaceLivenessDelegate {
.setStage(stage: cafStage)
.setFilter(filter: filter)
.setLoadingScreen(withLoading: setLoadingScreen!)
.setCredentials(mobileToken: token, personId: personId)
.build()
faceLiveness.delegate = self

DispatchQueue.main.async {
guard let currentViewController = UIApplication.shared.keyWindow!.rootViewController else { return }
faceLiveness.startSDK(viewController: currentViewController)
faceLiveness.startSDK(viewController: currentViewController, mobileToken: token, personId: personId)
}
}


// FaceLiveness
func didFinishLiveness(with faceLivenessResult: FaceLiveness.FaceLivenessResult) {
func didFinishLiveness(with livenessResult: LivenessResult) {
let response : NSMutableDictionary = [:]
response["data"] = faceLivenessResult.signedResponse
response["data"] = livenessResult.signedResponse
sendEvent(withName: "FaceLiveness_Success", body: response)
}

func didFinishWithFail(with faceLivenessFailResult: FaceLiveness.FaceLivenessFailResult) {
let response : NSMutableDictionary = [:]
response["message"] = faceLivenessFailResult.description
response["type"] = String(describing: faceLivenessFailResult.failType)
response["data"] = String(describing: faceLivenessFailResult.signedResponse)
sendEvent(withName: "FaceLiveness_Error", body: response)
}

func didFinishWithCancelled(with faceLivenessResult: FaceLiveness.FaceLivenessResult) {
func didFinishWithCancelled() {
sendEvent(withName: "FaceLiveness_Cancel", body: nil)
}

func didFinishWithError(with faceLivenessErrorResult: FaceLiveness.FaceLivenessErrorResult) {
func didFinishWithError(with sdkFailure: SDKFailure) {
let response : NSMutableDictionary = [:]
response["message"] = faceLivenessErrorResult.description
response["type"] = String(describing: faceLivenessErrorResult.errorType)
response["message"] = sdkFailure.description
response["type"] = String(describing: sdkFailure.errorType)
sendEvent(withName: "FaceLiveness_Error", body: response)
}

Expand All @@ -115,4 +107,5 @@ class CafFaceLiveness: RCTEventEmitter, FaceLivenessDelegate {
func closeLoadingScreenValidation() {
sendEvent(withName: "FaceLiveness_Loaded", body: nil)
}
func onConnectionChanged(_ state: FaceLiveness.LivenessState) {}
}

0 comments on commit 4964e93

Please sign in to comment.