# Callbacks and handlers for Android SDK

# SDK state change notification

To receive notifications about SDK state changes, use .withHandlers(onStateChanged = onSDKStateChangedHandler) or .withStateChangedHandler(stateChangedHandler) in CBRMobileSDK.Builder.

The handler receives two parameters:

  • newState — the current SDK state.
  • prevState — the previous SDK state.

Example listing all possible states:

# Event notifications

The event handler allows you to stay informed about events occurring during processing.

Events are passed to the handler as instances of classes derived from the base class CBREvent. Each event therefore has an eventType and a set of parameters packed into a payload dictionary.

Depending on your needs, you can access event parameters either by analyzing the payload directly or by casting the passed event instance to the corresponding CBREvent* class based on its type.

# SDK completion notification

An optional handler to receive notifications when the SDK is closed.

The handler receives two parameters:

  • result:
    • CBRCompletionResult.SuccessTermination — successful SDK termination, including a call to dismiss().
    • CBRCompletionResult.AbnormalTermination — an error occurred during SDK operation. Additional information can be obtained from the exception object.
  • state: the SDK state at the time of closure. Possible states are listed in SDK state change notification.

# Token expiration

Since the access token (accessToken) has a limited lifespan, it is important to be able to refresh it. To do this, pass a tokenHandler to CBRMobileSDK.Builder.

The handler requests a new token from your server and then provides it back to the SDK.

Warning:

onTokenExpired should not be called on the UI thread.

# SDK error notification

To receive error notifications, use .withHandlers(onError = onSDKErrorHandler) or .withErrorHandler(errorHandler) in CBRMobileSDK.Builder.

# Action result notification

This handler can be used to receive the result of an applicant action and to manage the face liveness check scenario.

The handler receives two parameters:

  • actionId: String — the identifier of the applicant action.
  • answer: String — the response from the face liveness check module.
    Possible values: GREEN / YELLOW / RED / ERROR / null.

The handler should return a CBRActionResult:

  • CBRActionResult.Continue — continue the default action scenario (for example, show the result screen).
  • CBRActionResult.Cancel — cancel the default action scenario (close the SDK without showing the result screen).

# Icon handler

This handler allows you to customize icons on IDnGO SDK screens. Currently, only instruction icons and document icons (for the document selection screen) are supported.

The handler provides the icon key and thematic context, returning a drawable or null if no drawable is required.

SDK uses the following keys:

  • default/do_idCard — icon for identity document instructions (instruction screen, DO block).
  • default/dont_idCard — icon for identity document instructions (instruction screen, DON'T block).
  • default/do_idCard_backSide — icon for instructions for the back side of the identity document (instruction screen, DO block).
  • default/dont_idCard_backSide — icon for instructions for the back side of the identity document (instruction screen, DON'T block).
  • default/do_passport — icon for passport instructions (instruction screen, DO block).
  • default/dont_passport — icon for passport instructions (instruction screen, DON'T block).
  • default/facescan — icon for face liveness check instructions.
  • IdentityType/<DOCUMENT TYPE> — icon for a document item on the document selection screen, where <DOCUMENT TYPE> can be PASSPORT, DRIVERS, RESIDENCE_PERMIT, or another document.
  • Flag/<COUNTRY_CODE> — icon for a country flag, where <COUNTRY_CODE> is the Alpha-2 code (ISO 3166-1).

You can provide your own icons or override existing ones by extending CBRDefaultIconHandler.