100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
#19 APNS notification mutable-content attribute specification through FCM needed to be done differently, fixed.
Eric Bariauxa904b763f7e1
diff --git a/manager/server/src/main/java/org/openremote/manager/server/notification/FCMMessage.java b/manager/server/src/main/java/org/openremote/manager/server/notification/FCMMessage.javaindex 8158a94b1..8ddb9adcc 100644--- a/manager/server/src/main/java/org/openremote/manager/server/notification/FCMMessage.java+++ b/manager/server/src/main/java/org/openremote/manager/server/notification/FCMMessage.java@@ -19,16 +19,20 @@*/package org.openremote.manager.server.notification;+import com.fasterxml.jackson.annotation.JsonProperty;+public class FCMMessage extends FCMBaseMessage {protected Notification notification;protected boolean contentAvailable;+ protected boolean mutableContent;protected String priority;- public FCMMessage(Notification notification, boolean contentAvailable, String priority, String to) {+ public FCMMessage(Notification notification, boolean contentAvailable, boolean mutableContent, String priority, String to) {super(to);this.notification = notification;this.contentAvailable = contentAvailable;+ this.mutableContent = mutableContent;this.priority = priority;}@@ -40,6 +44,7 @@ public class FCMMessage extends FCMBaseMessage {this.notification = notification;}+ @JsonProperty("content_available")public boolean getContentAvailable() {return contentAvailable;}@@ -48,6 +53,15 @@ public class FCMMessage extends FCMBaseMessage {this.contentAvailable = contentAvailable;}+ @JsonProperty("mutable_content")+ public boolean getMutableContent() {+ return mutableContent;+ }++ public void setMutableContent(boolean mutableContent) {+ this.mutableContent = mutableContent;+ }+public String getPriority() {return priority;}@@ -61,6 +75,7 @@ public class FCMMessage extends FCMBaseMessage {return getClass().getSimpleName() + "{" +"notification=" + notification +", contentAvailable=" + contentAvailable ++ ", mutableContent=" + mutableContent +", priority='" + priority + '\'' +'}';}diff --git a/manager/server/src/main/java/org/openremote/manager/server/notification/Notification.java b/manager/server/src/main/java/org/openremote/manager/server/notification/Notification.javaindex 2a1371253..1eb06b01d 100644--- a/manager/server/src/main/java/org/openremote/manager/server/notification/Notification.java+++ b/manager/server/src/main/java/org/openremote/manager/server/notification/Notification.java@@ -24,13 +24,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;public class Notification {protected String body;- protected boolean mutableContent;protected String clickAction = "openremoteNotification";- public Notification(String body, boolean mutableContent) {+ public Notification(String body) {super();this.body = body;- this.mutableContent = mutableContent;}public String getBody() {@@ -41,15 +39,6 @@ public class Notification {this.body = body;}- @JsonProperty("mutable-content")- public boolean getMutableContent() {- return mutableContent;- }-- public void setMutableContent(boolean mutableContent) {- this.mutableContent = mutableContent;- }-public String getClickAction() {return clickAction;}@@ -58,7 +47,6 @@ public class Notification {public String toString() {return getClass().getSimpleName() + "{" +"body='" + body + '\'' +- ", mutable-content=" + mutableContent +", clickAction='" + clickAction + '\'' +'}';}diff --git a/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java b/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.javaindex 7fa1e3c44..29fb76d1f 100644--- a/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java@@ -140,13 +140,13 @@ public class NotificationService implements ContainerService {for (DeviceNotificationToken notificationToken : allTokenForUser) {try {Invocation.Builder builder = firebaseTarget.request().header("Authorization", "key=" + fcmKey);- Notification notification = new Notification("_", true);+ Notification notification = new Notification("_");FCMBaseMessage message;if ("ANDROID".equals(notificationToken.getDeviceType())) {message = new FCMBaseMessage(notificationToken.getToken());} else {- message = new FCMMessage(notification, true, "high", notificationToken.getToken());+ message = new FCMMessage(notification, true, true, "high", notificationToken.getToken());}LOG.fine("Sending notification message to device of user '" + userId + "': " + message);Response response = builder.post(Entity.entity(message, "application/json"));