Update to newer version of GCM server which lets Usergrid directly set the data object within the SDK instead of just adding key/value pairs.
diff --git a/stack/pom.xml b/stack/pom.xml
index f052bf9..a94233e 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -121,7 +121,7 @@
<antlr.version>3.4</antlr.version>
<tika.version>1.4</tika.version>
<mockito.version>1.10.8</mockito.version>
- <io.apigee.gcm.version>1.0.0</io.apigee.gcm.version>
+ <io.apigee.gcm.version>1.0.1</io.apigee.gcm.version>
<!-- only use half the cores on the machine for testing -->
<usergrid.it.parallel>methods</usergrid.it.parallel>
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index af0bc78..7929ad4 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -242,14 +242,10 @@
payload.remove(priorityKey);
}
-//
-// // add our source notification payload data into the Message Builder
-// // Message.Builder requires the payload to be Map<String,String> so blindly cast
-// Map<String,String> dataMap = (Map<String,String>) payload;
-//
-// dataMap.forEach( (key, value) -> builder.addData(key, value));
- builder.addData("data", JSON.toString(payload));
+ builder.setData(payload);
+ // GCM will accept Map<String,Object> but builder.build().toString() will throw a class cast
+ // exception, but luckily Message.toString() is not used anywhere in the GCM SDK or Usergrid
Message message = builder.build();
MulticastResult multicastResult;
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 8782fe3..77abb56 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -167,6 +167,38 @@
}
@Test
+ public void singlePushNotificationMapPayload() throws Exception {
+
+ app.clear();
+ Map<String, Object> topLevel = new HashMap<>();
+ Map<String, String> mapPayload = new HashMap<String, String>(){{
+ put("key1", "value1");
+ put("key2", "value2");
+
+ }};
+ topLevel.put("enabler", mapPayload);
+ Map<String, Object> payloads = new HashMap<>(1);
+ payloads.put(notifier.getUuid().toString(), topLevel);
+ app.put("payloads", payloads);
+ app.put("queued", System.currentTimeMillis());
+ app.put("debug", true);
+ app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time
+
+ Entity e = app.testRequest(ServiceAction.POST, 1, "devices", device1.getUuid(), "notifications").getEntity();
+ app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
+
+ Notification notification = app.getEntityManager().get(e.getUuid(), Notification.class);
+
+ //assertEquals(
+ // notification.getPayloads().get(notifier.getUuid().toString()),
+ // payload);
+
+ // perform push //
+ notification = notificationWaitForComplete(notification);
+ checkReceipts(notification, 1);
+ }
+
+ @Test
public void singlePushNotificationNoReceipts() throws Exception {
app.clear();