# iOS SDK callbacks and handlers

Handlers and callbacks are optional. Use them if required, but we recommend setting at least tokenExpirationHandler to ensure that the access token remains valid.

# Status update notification

Use the onStatusDidChange callback to receive notifications about verification process steps.

This callback takes two parameters:

  • sdk — the SDK instance,
  • prevStatus — the previous status.

After that, you can check sdk.status to determine the current verification status.

# Event notification

Use the onEvent callback to receive notifications about events that occur during processing.
Each event is passed as an instance of a class inherited from the base class CBREvent. Every event includes: eventType — the event type, payload — a dictionary containing event parameters.

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

# SDK completion notification

Use the onDidDismiss callback to receive a notification when the SDK is closed.

# Token expiration

Since the access token (accessToken) has a limited lifetime, you need to handle the case when it expires and must be refreshed.

The tokenExpirationHandler calls your server, retrieves a new token, and then provides it back to the SDK by calling the onComplete closure.

The onComplete closure must be called even if you cannot provide a new token, in that case, pass nil.

# Verification completion

Use the verificationHandler to get a notification when the verification process has finished with a final decision.

The isApproved parameter indicates whether the applicant was approved or finally rejected. If you want to receive notifications about other verification statuses, use onStatusDidChange. See Status update notifications for details.

# Dismissal control

You can take control of SDK dismissal by assigning a dismissHandler. The handler receives the current sdk instance and the mainVC controller. You can close mainVC in any way you see fit.