Handling Events, Callbacks, and Completions

Overview

Handling events that happen with the SDK can allow for a richer UX experience for your end users. We recommend you handle each event (if applicable) that happen within each component of the library.

Before continuing, make sure you have read Integrating Push Notifications to allow for proper remote event handling involving the AuthenticatorManager and AuthRequestManager. Opting to skip this section will only allow for local events to trigger.

Many of our method calls are asynchronous events. As such, they should be handled appropriately to correctly display the proper information back to the end-user. Both platforms handle each event in a similar manner internally but may require different approaches.

For Android, we allow for EventCallback and Event objects to be registered with the appropriate manager. Some method calls also allow for specific EventCallback and Callback objects to be passed in as an argument callback. Be careful when using both the event system through the SDK’s managers and the callback approach as this may lead to multiple calls to the same event.

For iOS, we allow for Completion blocks to be included in many of our function calls. Observers can also be registered through the NSNotificationCenter.

Authentication Management Events

These events are triggered through calls involving the AuthenticatorManager.

Each EventCallback has an onSuccess() and onFailure() method. They may also be registered as events by the manager.

EventCallbacks for AuthenticatorManager
EventCallback Description onSuccess() onFailure()
DeviceLinkedEventCallback Notified after the current device gets linked Device (The current device) Exception
DeviceUnlinkedEventCallback Notified after the current device gets unlinked Device (The current device) Exception
EndAllSessionsEventCallback Notified after endAllSessions() finishes Void Exception
EndSessionEventCallback Notified after endSession() finishes Session Exception
GetDevicesEventCallback Notified after getDevices() finishes List<Device> Exception
GetSessionsEventCallback Notified after getSessions() finishes List<Session> Exception
UnlinkDeviceEventCallback (Any Device was unlinked) Notified when any device for this user is unlinked and push is turned on Device (The unlinked device) Exception

Auth Request Management Events

These events are triggered through calls involving the AuthRequestManager.

Each have an onSuccess() and onFailure() method. They may also be registered as events by the manager.

Events & EventCallbacks for AuthRequestManager
Event / EventCallback Description onSuccess() onFailure()
AuthRequestPushReceivedEvent Notified when a push notification is received for an auth request Void Exception
AuthRequestResponseEvent Notified after the End User has attempted to respond to a pending Auth Request AuthRequestResponse Exception
GetAuthRequestEventCallback Notified after a check is made to obtain a pending Auth Request AuthRequest Exception

Example: Auth Request received and responded

AuthRequestResponseEventCallback authRequestResponseEventCallback = new AuthRequestResponseEventCallback() {
    @Override public void onSuccess(@NonNull AuthRequestResponse authRequestResponse) {
        displayAuthRequestResponse(authRequestResponse);
    }

    @Override public void onFailure(@NonNull Exception e) {
        handleFailure(e);
    }
};

GetAuthRequestEventCallback getAuthRequestEventCallback = new GetAuthRequestEventCallback() {
    @Override public void onSuccess(@Nullable AuthRequest authRequest) {
        if (authRequest != null) {
            displayAuthRequest(authRequest);
        }
    }

    @Override public void onFailure(@NonNull Exception e) {
        handleFailure(e);
    }
};

@Override
public void onResume() {
    ...

    authRequestManager.registerForEvents(authRequestResponseEventCallback, getAuthRequestEventCallback);
}

@Override
public void onPause() {
    authRequestManager.unregisterForEvents(authRequestResponseEventCallback, getAuthRequestEventCallback);

    ...
}

Auth Method Management Events

These events are triggered through callbacks/completions with certain Auth Method Managers.

PINCodeManager & CircleCodeManager both use the same callbacks. Each callback has a onVerificationSuccess() and onVerificationFailure().

Callbacks for PINCodeManager & CircleCodeManager
Callback Description onVerificationSuccess() onVerificationFailure()
AuthMethodVerificationCallback Used whenever a user’s auth method must be verified. Called after changeVerificationFlag(), removePINCode(), removeCircleCode() finishes. null
  • AuthMethodFailure,
  • boolean if an an unlink triggered,
  • boolean if an unlink warning triggered,
  • Integer representing attempts remaining before an auto-unlink occurs.
AuthMethodAuthRequestVerificationCallback Used whenever a user’s auth method must be verified specifically for an auth request. boolean if an auth request was sent as a result of failing verification of this Auth Method.
  • boolean if an auth request was sent as a result of failing verification of this Auth Method,
  • AuthMethodFailure,
  • boolean if an an unlink triggered,
  • boolean if an unlink warning triggered,
  • Integer representing attempts remaining before an auto-unlink occurs.

Some callback calls may have different onSuccess() and onFailure method signatures (i.e. onAddSuccess() vs onRemoveSuccess()).

Callbacks for WearablesManager
Callback Description onSuccess() onFailure()
AddWearableCallback Used when adding a Wearable via addWearable() null Exception
RemoveWearableCallback Used when removing a Wearable via removeWearable() null Exception
CancelRemoveWearableCallback Used when cancelling the removal of a Wearable via cancelRemoveWearable() null Exception
GetAvailableWearablesCallback Used when getting the available list of Wearable objects via getAvailableWearables() List<Wearable> Exception
GetStoredWearablesCallback Used when getting the set list of Wearable objects via getStoredWearables() List<Wearable> Exception
GetWearablesVerificationFlagCallback Used when getting the VerificationFlag via getVerificationFlag() VerificationFlag Exception
ChangeWearablesVerificationFlagCallback Used when changing the VerificationFlag via changeVerificationFlag() VerificationFlag (new) Exception
Callbacks for BiometricManager
Callback Description onSuccess() onFailure()
SetBiometricCallback Used when setting a Biometric via setBiometric() null Failure
AuthMethodVerificationCallback Used whenever a user’s auth method must be verified. Called after changeVerificationFlag(), removePINCode(), removeCircleCode() finishes. null
  • AuthMethodFailure,
  • boolean if an an unlink triggered,
  • boolean if an unlink warning triggered,
  • Integer representing attempts remaining before an auto-unlink occurs.
AuthMethodAuthRequestVerificationCallback Used whenever a user’s auth method must be verified specifically for an auth request. boolean if an auth request was sent as a result of failing verification of this Auth Method.
  • boolean if an auth request was sent as a result of failing verification of this Auth Method,
  • AuthMethodFailure,
  • boolean if an an unlink triggered,
  • boolean if an unlink warning triggered,
  • Integer representing attempts remaining before an auto-unlink occurs.
Callbacks for LocationsManager
Callback Description onSuccess() onFailure()
AddLocationCallback Used when adding a Location via addLocation() null Exception
RemoveLocationCallback Used when removing a Location via removeLocation() null Exception
CancelRemoveLocationCallback Used when cancelling the removal of a Location via cancelRemoveLocation() null Exception
GetStoredLocationsCallback Used when getting the set list of Location objects via getStoredLocations() List<StoredLocation> Exception
GetLocationsVerificationFlagCallback Used when getting the VerificationFlag via getVerificationFlag() VerificationFlag Exception
ChangeLocationsVerificationFlagCallback Used when changing the VerificationFlag via changeVerificationFlag() VerificationFlag (new) Exception
Callbacks for GeofencesManager
Callback Description onVerificationSuccess() onVerificationFailure()
AuthMethodAuthRequestVerificationCallback Used whenever a user’s auth method must be verified specifically for an auth request. boolean if an auth request was sent as a result of failing verification of this Auth Method.
  • boolean if an auth request was sent as a result of failing verification of this Auth Method,
  • AuthMethodFailure,
  • boolean if an an unlink triggered,
  • boolean if an unlink warning triggered,
  • Integer representing attempts remaining before an auto-unlink occurs.

User Contributed

TransUnion links to user contributed code as a resource to its community. TransUnion does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to TransUnion immediately and we will investigate the claim. Submit any issue to TransUnion support at https://transunion.com/support. ×