Setting up Push Notifications

TransUnion recommends adding push notifications to your integrations in order to provide a better experience for End Users. We also recommend providing a mechanism to manually check for pending Auth Requests, because push notifications depend on many interrelated systems to work, such as mobile carrier availability and performance in Google’s own infrastructure, and are not guaranteed to reach the device(s).

Read Integrating Push Notifications for Android for Android or Integrating Push Notifications for iOS for iOS.

Integrating Push Notifications for Android

The recommended approach for setting up Push Notifications is through the Firebase console and Android library dependency through gradle.

The steps are as follows:
  1. Register your app with Firebase
  2. Add the Firebase server key to Admin Center
  3. Handle and receive Push Notifications

Register your app with Firebase

Follow the official documents to Set up a Firebase Cloud Messaging client app. Ensure you have the correct dependencies and a google-services.json file included in your application’s app directory.

Add the Firebase server key to Admin Center

  1. From the Firebase console, open the project settings and navigate to the Cloud Messaging tab.
  2. If a server key is not already added, click Add server key.
  3. Copy the server key’s token.
  4. From the TruValidate Multifactor Authentication Admin Center, find your Organization and open your Directory.
  5. Navigate to Push Notifications and paste/save the key under the field Android Server API Key.

Handle and receive Push Notifications

To begin, the SDK must have the push device token setup. You must have a FirebaseMessagingService extended service class. Override onNewToken() and call the appropriate AuthenticatorManager method.

@Override
public void onNewToken(String newToken) {
    super.onNewToken(newToken);
    ...

    AuthenticatorManager.instance.setPushDeviceToken(newToken);
}

To correctly propagate the push notification, we must have the AuthenticatorManager handle the payload.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    ...
    // create and display the notification to the end user here
    ...
    AuthenticatorManager.instance.handlePushPayload(remoteMessage.getData());
}

Note

If you are processing push notifications outside of TruValidate, registering tokens is not required.

Processing notifications outside of TruValidate systems

If you are managing your own push notifications outside of TransUnion, we must have the AuthenticatorManager handle the push package.

...
// create and display the notification to the end user here
...
AuthenticatorManager.instance.handleThirdPartyPushPackage(pushPackageString);

Integrating Push Notifications for iOS

  1. Register for an Apple Push Notification Token
  2. Register the Device token with the SDK
  3. Obtain an Apple Push Notification Certificate
  4. Set up interception of push notifications

Note

In order for push notifications to work properly in a multi-target environment, each product name of each target needs to be unique.

Register for an Apple Push Notification Token

To identify a device and to receive push notifications from the TruValidate Multifactor Authentication platform, you must register for an Apple Push Notification token:

UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

Register the Device Token with the SDK

You must register the device token with the Authenticator SDK using the didRegisterForRemoteNotificationsWithDeviceToken function in the AppDelegate callback.

[[LKCAuthenticatorManager sharedClient] setPushDeviceToken:deviceToken];

Note

If you are processing push notifications outside of TruValidate, registering tokens is not required.

Obtain an Apple Push Notification Certificate

You must obtain an Apple Push Notification Certification before the TruValidate Multifactor Authentication platform can send push notifications to your mobile app. These instructions assume that you have already set up push notifications for your app. To do this:

  1. Log in to the Apple Developer Portal
  2. Click the Certifications, IDs & Profiles section.
  3. Under Certificates, locate the Production Push Notification certificate that you create for your app (the same certificate that you use in production now for your app). Download the certificate.
  4. Double-click the local certificate file to add it to your keychain’s Certificate section.
  5. Open Keychain Access.
  6. Select Certificates and click the arrow beside the certificate you just downloaded. This displays the associated key. Select both the certificate and key, right-click and choose Export 2 items.
  7. Save the certificate with a .p12 file extension and leave the password field empty.
  8. From the TruValidate Multifactor Authentication Admin Center, find your Organization and open your Directory.
  9. Navigate to Push Notifications and upload your certificate under the iOS section.

Set up interception of Push Notifications

In order to intercept push notifications, use the didReceiveRemoteNotification callback in the AppDelegate. Pass the userInfo to the following call and add the requestReceived observer.

[[LKCAuthenticatorManager sharedClient] handlePushPayload:userInfo];

Note

When the app is launched, push notifications arrive in didReceiveRemoteNotification. If the app is closed, the push payload is sent to didFinishLaunchingWithOptions within the launchOptions dictionary.

Processing notifications outside of TruValidate systems

If you are managing your own push notifications outside of TruValidate, we must have the LKCAuthenticatorManager shared client handle the push package string.

[[LKCAuthenticatorManager sharedClient] handleThirdPartyPushPackage:@"push_package_string"];

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. ×