Receive push notification

This topic explains how to set up your push notification service on your application. Complete this step if you are using the Identity Platform MFA methods push-to-accept, symbol-to-accept, or biometric. If you are using only TOTP, see "Generate offline TOTP" for steps.

At this point in the workflow, end users will request a second factor and must receive a push notification on their mobile device in your app.

Push notifications are sent as data types. You will receive notifications on onMessageReceived. Your application is responsible for showing the notification to the end user. For more information about managing the data type, see the external document, Receive messages in an Android app.

Add the following to the MessageService class.

class MessageService: FirebaseMessagingService() {
 
    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        try {
            // Parse remote message data
            val secureAuthNotification = SecureAuthNotification(remoteMessage.data)
             
            // Process and show push notifications
            // To show push notifications, check "secureAuthNotification.pushType"
            // PUSH_TYPE_DEFAULT -> Only msg notification
            // PUSH_TYPE_PAN -> Push to accept notification
            // PUSH_TYPE_SPAN -> Symbol to accept notification
            // PUSH_TYPE_BPAN -> Biometric to accept notification
            processSecureAuthNotification(secureAuthNotification)
        } catch (malformedDataNotification: MalformedDataNotification) {
            // Catch MalformedDataNotification error
        }
    }
     
    // Update push notification token every time the token changes
    override fun onNewToken(newToken: String) {
        ApplicationUtil.setToken(this, newToken)
    }
     
}

Next steps

Reply to push notification