Integration

Runtime permissions

If your application does not request it in advance, Identity will request permission at the time it is needed for CAMERA. If your policy uses location context, your application must request ACCESS_FINE_LOCATION permission.

PermissionReasonRequired

CAMERA

Capturing the selfie in policies with facial re-authentication

No

ACCESS_FINE_LOCATION

Get data on policies with location context

Yes, if the policy uses localization context

Instantiating the SDK

First, create an object of type Identity. This object is for you to configure all your business rules:

Identity identity = new Identity.Builder(String mobileToken, this)
    .build();

Builder method

ParameterRequired

String mobileToken

Usage token associated with your Identity account (see how to get it here).

Yes

Context context

Application context.

Yes

.setEmailUrl(String url)

Used to redirect the user to a custom link in the outgoing Email flow.

No

.setPhoneUrl(String url)

Used to redirect the user to a custom link in the SMS sending flow.

No

.setStage(CAFStage stage)

Allows you to choose the environment in wich the SDK will run (production, beta).

No. The default is CAFStage.PROD

.setFaceAuthenticatorSettings(FaceAuthenticatorSettings settings)

Used to configure the facial authentication feature.

No. It is only necessary if your policy includes facial authentication.

FaceAuthenticatorSettings

ParameterRequired

String faceAuthToken

Token associated with your Trust account (see how to get it here).

Yes

Boolean useLoadingScreen

Used to enable a default loading progressbar during loading events.

No

Boolean enableScreenshots

Used to enable screenshots during the SDK scan. Disabled by default for security reasons.

No

FilterStyle filter

Used to change the SDK filter. It has the following options:

FilterStyle.NATURAL

FilterStyle.LINE_DRAWING

No

Consulting a policy

To authenticate a user, use the verifyPolicy method. You must enter the user's CPF and the identifier of the policy to be used.

Parameters

ParameterRequired

String personId

User CPF

Yes

String policyId

Policy identifier

Yes

VerifyPolicyListener listener

Response Listener

Yes

Example

identity.verifyPolicy("{personId}", "{policyId}", new VerifyPolicyListener() {

    @Override
    public void onSuccess(boolean isAuthorized, String attestation) {
        if(isAuthorized){
            // Authorized user
            // Send attestation to your backend and perform validation
        }else{
            // Unauthorized user
        }
    }

    @Override
    public void onPending(boolean isAuthorized, String attestation) {
        // Authorization is pending manual approval
    }

    @Override
    public void onError(Failure failure) {
        // Error when running the SDK
        // See below
    }
});

isAuthorized Status

CaseStatus

No Registered face

False

Fraud or no match

False

User approved

True

Attestation return

The attestation will be available after the user authentication.

Example

    isAuthorized = true
    attestation = {value}

Handling errors

Some errors can prevent Identity from running. To identify them, check the instance of the Failure object class.

instanceOfDescriptionExample

PermissionReason

You are missing some mandatory permission

Start facial authentication without camera permission granted

AvailabilityReason

Identity is not available for use. The variable Failure.getMessage() contains instructions for the user

The device's internal storage is full when installing the app, and it is not possible to install the face detection template together

NetworkReason

Internet connection failure

The user was without internet during face authentication

ServerReason

When a requisition receives a status code of failure

In theory, it shouldn't happen. If you see something like this, let us know!

SecurityReason

When Identity cannot be started due to a security reason

When Google Security Provider is not updating

StorageReason

There is no space on the user device's internal storage

When there is no space on the internal storage while capturing the document photo

LibraryReason

When an internal library cannot be started

Forgetting to set noCompress configuration will lead to this failure in DocumentDetector

PolicyReason

You are using a policy that we do not yet support. The variable Failure.getMessage() contains instructions for the developer

Use a policy with localization context

Example

@Override
public void onError(Failure failure) {
    if (failure.getMessage().equals("Cancelled")) {
        // the user closed the activity
    } else if (failure instanceof PermissionReason) {
        // permission must be granted by the user to start the SDK
    } else if (failure instanceof AvailabilityReason) {
        // the String sdkFailure.getMessage() contains instructions to the user
    } else if (failure instanceof NetworkReason) {
        // internet connection failure
    } else if (failure instanceof ServerReason) {
        // there was a problem in any communication with the CAF servers, let us know!
    } else if (failure instanceof SecurityReason) {
        // some security reason on the user's device prevents the use of the SDK
    } else if (failure instanceof StorageReason) {
        // ask your user to free up internal storage space
    } else if (failure instanceof LibraryReason) {
        // some internal library encountered problems running
    } else if(failure instanceof PolicyReason) {
        // you are using a policy that we do not yet support
    }
}

Last updated

Logo

2023 © Caf. - All rights reserved