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
Adapted FCM notifications for iOS compatibility
William Balcaen07e807c26d1d
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 face5f8af..5945a2292 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@@ -3,17 +3,45 @@ package org.openremote.manager.server.notification;public class FCMMessage {- private String to;+ private Notification notification;+ private boolean content_available;+ private String priority;+ private String to;- public FCMMessage(String to) {- this.to = to;- }- public String getTo() {- return to;- }- public void setTo(String to) {- this.to = to;- }-}+ public FCMMessage(Notification notification, boolean content_available, String priority, String to) {+ super();+ this.notification = notification;+ this.content_available = content_available;+ this.priority = priority;+ this.to = to;+ }++ public Notification getNotification() {+ return notification;+ }+ public void setNotification(Notification notification) {+ this.notification = notification;+ }+ public boolean getContent_available() {+ return content_available;+ }+ public void setContent_available(boolean content_available) {+ this.content_available = content_available;+ }+ public String getPriority() {+ return priority;+ }+ public void setPriority(String priority) {+ this.priority = priority;+ }+ public String getTo() {+ return to;+ }+ public void setTo(String to) {+ this.to = to;+ }+++}\ No newline at end of filediff --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.javanew file mode 100644index 000000000..e432858f4--- /dev/null+++ b/manager/server/src/main/java/org/openremote/manager/server/notification/Notification.java@@ -0,0 +1,34 @@+package org.openremote.manager.server.notification;++public class Notification {++ String body;+ boolean mutable_content;+ String click_action = "blok61Notification";++ public Notification(String body, boolean mutable_content) {+ super();+ this.body = body;+ this.mutable_content = mutable_content;+ }++ public String getBody() {+ return body;+ }++ public void setBody(String body) {+ this.body = body;+ }++ public boolean getMutable_content() {+ return mutable_content;+ }++ public void setMutable_content(boolean mutable_content) {+ this.mutable_content = mutable_content;+ }++ public String getClick_action() {+ return click_action;+ }+}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 3f1c1a3fa..426c37629 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@@ -114,7 +114,9 @@ public class NotificationService implements ContainerService {for (DeviceNotificationToken notificationToken : allTokenForUser) {try {Invocation.Builder builder = target.request().header("Authorization", "key=" + fcmKey);- Response response = builder.post(Entity.entity(new FCMMessage(notificationToken.getToken()), "application/json"));+ Notification notification = new Notification("_", true);++ Response response = builder.post(Entity.entity(new FCMMessage(notification, true, "high", notificationToken.getToken()), "application/json"));if (response.getStatus() != 200) {LOG.severe("Error send FCM notification status=[" + response.getStatus() + "], statusInformation=[" + response.getStatusInfo() + "]");}