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.

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

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

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 onError(Failure failure) {
        // Error when running the SDK
        // See below
    }
});

isAuthorized Status

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.

Example

@Override
public void onError(Failure failure) {
    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
    } else if(failure == null){
        // the user closed the activity
    }
}

Last updated

Logo

2023 © Caf. - All rights reserved