LogoSignature Service
SmartContract SDKAndroid SDK

Push notifications

In order to receive push notifications sent by the security server, you need to register the push notification token to the server.

Follow official documentation to set up Firebase in your app and retrieve the Firebase token. Once available, it must be sent to the server, using the Services.registerPushNotificationToken(String) method.

The SDK provides a convenient way to retrieve the Firebase configuration configured server-side for the app (Services.getFirebaseMessagingOptions()).

The FirebaseMessagingService service can be implemented like below to handle notifications sent by the security server.

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    String actionString = remoteMessage.getData().get(PushNotificationMessageData.SECURITY_ACTION);
    String userMessage = remoteMessage.getData().get(PushNotificationMessageData.USER_MESSAGE);
    String badge = remoteMessage.getData().get(PushNotificationMessageData.BADGE);
    if (actionString != null) {
      PushNotificationMessageData.Action action = PushNotificationMessageData.Action.valueOf(actionString);
      switch (action) {
        case UPDATE_SECURITY_SETTINGS:
        case CLOSE_SESSION:
          // Session closed server-side
          break;
      }
    }
  }
}