Class FcmAppNotificationHandlerImpl

  • All Implemented Interfaces:
    AppNotificationHandler

    @Component
    public class FcmAppNotificationHandlerImpl
    extends BaseNetworkedHandlerImpl
    implements AppNotificationHandler
    Firebase Cloud Messaging (FCM) app notification handler implementation.

    There are two types of messages that can be sent to clients:
    • Notification messages: handled automatically by the platform (FCM shows the notification message on the device)
    • Data messages: handled directly by the app
    Please follow this link for a detailed description: About FCM messages
    This is the link to the API doc: API Reference

    This implementation send notification messages with a data payload of custom key-value pairs. The data payload is stored in AppNotificationMessage.getVariables()
    • Constructor Detail

      • FcmAppNotificationHandlerImpl

        public FcmAppNotificationHandlerImpl()
    • Method Detail

      • canReceiveNotifications

        public boolean canReceiveNotifications​(BasicUser user)
        Description copied from interface: AppNotificationHandler
        Returns whether the app notifications are configured for the user and if it also has the required mediums to receive it (e.g an FCM registration token).
        If false no notifications will be sent to this specific user.
        Specified by:
        canReceiveNotifications in interface AppNotificationHandler
      • destroy

        public void destroy()
      • initialize

        @PostConstruct
        public void initialize()
      • instantiateApp

        public com.google.firebase.FirebaseApp instantiateApp​(String credentials)
                                                       throws AppNotificationException
        Initializes the Firebase SDKs with the given credentials and store it in the local storage with an one-day of expiration.
        Parameters:
        credentials - the JSON private key
        Returns:
        the initialized instance
        Throws:
        AppNotificationException - if any error has occurred during initialization
      • validate

        public void validate​(BasicUser user,
                             Object medium)
        Description copied from interface: AppNotificationHandler
        Validates the given medium used to send the app notification to the user. The medium depends on the underlying implementation, e.g in case of FCM it would be a token of type String.
        Specified by:
        validate in interface AppNotificationHandler