Class FCMMessagePublisher

java.lang.Object
org.exoplatform.push.service.fcm.FCMMessagePublisher
All Implemented Interfaces:
MessagePublisher

public class FCMMessagePublisher extends Object implements MessagePublisher
Message publisher using the HTTP API v1 of Firebase Cloud Messaging
  • Field Details

  • Constructor Details

    • FCMMessagePublisher

      public FCMMessagePublisher(org.exoplatform.container.xml.InitParams initParams, org.exoplatform.services.resources.ResourceBundleService resourceBundleService, org.exoplatform.commons.api.notification.service.WebNotificationService webNotificationService)
    • FCMMessagePublisher

      public FCMMessagePublisher(org.exoplatform.container.xml.InitParams initParams, org.exoplatform.services.resources.ResourceBundleService resourceBundleService, org.exoplatform.commons.api.notification.service.WebNotificationService webNotificationService, org.apache.http.impl.client.CloseableHttpClient httpClient)
  • Method Details

    • send

      public void send(Message message) throws Exception
      Specified by:
      send in interface MessagePublisher
      Throws:
      Exception
    • convertHtml

      protected String convertHtml(String html)
      Conserve line breaks of br and p elements in a html document
    • processBody

      protected String processBody(Message message)
      Process the notification message body: * replace images by a text "inline image" * escape double quotes
      Parameters:
      message - The raw message body
      Returns:
      The transformed message body
    • loadConfiguration

      protected FCMServiceAccountConfiguration loadConfiguration(String fcmServiceAccountFilePath) throws IOException
      Load Firebase Cloud Messaging configuration from file
      Parameters:
      fcmServiceAccountFilePath -
      Returns:
      Throws:
      IOException
    • getCredentialsFromStream

      protected com.google.api.client.googleapis.auth.oauth2.GoogleCredential getCredentialsFromStream(FCMServiceAccountConfiguration configuration) throws Exception
      Build GoogleCredential object from configuration
      Parameters:
      configuration - Firebase Cloud Messaging configuration
      Returns:
      GoogleCredential
      Throws:
      IOException
      GeneralSecurityException
      Exception
    • getPrivateKeyFromPkcs8

      protected PrivateKey getPrivateKeyFromPkcs8(String privateKeyPem) throws IOException
      Build a PrivateKey from its string value
      Parameters:
      privateKeyPem - Private key value
      Returns:
      PrivateKey
      Throws:
      IOException
    • getAccessToken

      protected String getAccessToken() throws IOException
      Retrieve the access token
      Returns:
      The access token
      Throws:
      IOException