Package org.exoplatform.push.service.fcm
Class FCMMessagePublisher
java.lang.Object
org.exoplatform.push.service.fcm.FCMMessagePublisher
- All Implemented Interfaces:
MessagePublisher
Message publisher using the HTTP API v1 of Firebase Cloud Messaging
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFCMMessagePublisher(org.exoplatform.container.xml.InitParams initParams, org.exoplatform.services.resources.ResourceBundleService resourceBundleService, org.exoplatform.commons.api.notification.service.WebNotificationService webNotificationService) 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 Summary
Modifier and TypeMethodDescriptionprotected StringconvertHtml(String html) Conserve line breaks of br and p elements in a html documentprotected StringRetrieve the access tokenprotected com.google.api.client.googleapis.auth.oauth2.GoogleCredentialgetCredentialsFromStream(FCMServiceAccountConfiguration configuration) Build GoogleCredential object from configurationprotected PrivateKeygetPrivateKeyFromPkcs8(String privateKeyPem) Build a PrivateKey from its string valueprotected FCMServiceAccountConfigurationloadConfiguration(String fcmServiceAccountFilePath) Load Firebase Cloud Messaging configuration from fileprotected StringprocessBody(Message message) Process the notification message body: * replace images by a text "inline image" * escape double quotesvoid
-
Field Details
-
LOG_SERVICE_NAME
- See Also:
-
LOG_OPERATION_NAME
- See Also:
-
-
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
- Specified by:
sendin interfaceMessagePublisher- Throws:
Exception
-
convertHtml
Conserve line breaks of br and p elements in a html document -
processBody
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:
IOExceptionGeneralSecurityExceptionException
-
getPrivateKeyFromPkcs8
Build a PrivateKey from its string value- Parameters:
privateKeyPem- Private key value- Returns:
- PrivateKey
- Throws:
IOException
-
getAccessToken
Retrieve the access token- Returns:
- The access token
- Throws:
IOException
-