From 8e9610b0a81f6954ed6339571aa166804ecb3c30 Mon Sep 17 00:00:00 2001 From: John Nilsen Date: Thu, 8 Dec 2016 10:14:01 +0100 Subject: [PATCH 1/4] Initial commit for the android notification structure PR --- doc/notifications-structure-android.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/notifications-structure-android.md diff --git a/doc/notifications-structure-android.md b/doc/notifications-structure-android.md new file mode 100644 index 0000000..a15bd5d --- /dev/null +++ b/doc/notifications-structure-android.md @@ -0,0 +1,13 @@ +# Android notification structure + +The current structure of the notification payload on android does not allow for customization on the client side. When a `notification` object is present the only customization possible is the notification icon and the primary color. + +## Proposed solution + +1. Add the data from the `notification` object to the `data` object. +2. Remove the `notification` object. + +The names of the fields in the `notification` object could be the same in the `data` object. This way the client has to manually handle their notifications, which gives it the liberty to customize the design. + +This solution would also be more extensible than the previous solution as it allows for custom fields (i.e. user avatars etc). + From 9e538f532d5e8204fc2090acb849ad1d7f9383d3 Mon Sep 17 00:00:00 2001 From: John Nilsen Date: Thu, 8 Dec 2016 10:16:41 +0100 Subject: [PATCH 2/4] fix typos --- doc/notifications-structure-android.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/notifications-structure-android.md b/doc/notifications-structure-android.md index a15bd5d..74fcc30 100644 --- a/doc/notifications-structure-android.md +++ b/doc/notifications-structure-android.md @@ -1,13 +1,13 @@ # Android notification structure -The current structure of the notification payload on android does not allow for customization on the client side. When a `notification` object is present the only customization possible is the notification icon and the primary color. +The current structure of the notification payload on android does not allow for customisation on the client side. When a `notification` object is present the only customisation possible is the notification icon and the primary color. ## Proposed solution 1. Add the data from the `notification` object to the `data` object. 2. Remove the `notification` object. -The names of the fields in the `notification` object could be the same in the `data` object. This way the client has to manually handle their notifications, which gives it the liberty to customize the design. +The names of the fields in the `notification` object could be the same in the `data` object. This way the client has to manually handle their notifications, which gives it the liberty to customise the design. This solution would also be more extensible than the previous solution as it allows for custom fields (i.e. user avatars etc). From 58ce105c7b9c7fcc24c782a51d5fd89122f2c214 Mon Sep 17 00:00:00 2001 From: John Nilsen Date: Thu, 8 Dec 2016 10:33:42 +0100 Subject: [PATCH 3/4] add further specification to android notification structure --- doc/notifications-structure-android.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/notifications-structure-android.md b/doc/notifications-structure-android.md index 74fcc30..8b844f7 100644 --- a/doc/notifications-structure-android.md +++ b/doc/notifications-structure-android.md @@ -4,7 +4,10 @@ The current structure of the notification payload on android does not allow for ## Proposed solution +Replace the notification message with a data message. Documentation on both types can be found [here](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages) + 1. Add the data from the `notification` object to the `data` object. +2. Put the `data` object on the top level 2. Remove the `notification` object. The names of the fields in the `notification` object could be the same in the `data` object. This way the client has to manually handle their notifications, which gives it the liberty to customise the design. From 83155020765f7b0e37582b68218d514ad75b4021 Mon Sep 17 00:00:00 2001 From: Alexander Simmerl Date: Thu, 8 Dec 2016 11:07:13 +0100 Subject: [PATCH 4/4] Update GCM mesasge structure To give more power to the client implementation for how to present notifications we move away from triggering system native notifications and just move to a plain data object container. This will help with extending the data model in the future. --- platform/sns/sns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/sns/sns.go b/platform/sns/sns.go index 4d9a329..cc05857 100644 --- a/platform/sns/sns.go +++ b/platform/sns/sns.go @@ -43,7 +43,7 @@ const ( fmtURN = `%s://%s` msgAPNS = `{"APNS": "{\"aps\": {\"alert\": \"%s\"}, \"urn\":\"%s\"}" }` msgAPNSSandbox = `{"APNS_SANDBOX": "{\"aps\": {\"alert\": \"%s\"}, \"urn\":\"%s\"}" }` - msgGCM = `{"GCM": "{\"notification\": {\"title\": \"%s\", \"data\": {\"urn\": \"%s\"}} }"}` + msgGCM = `{"GCM": "{\"data\": {\"title\": \"Social\", \"body\": \"%s\", \"urn\": \"%s\"} }" }` ) // PlatformIdentifiers helps to map Platfrom to human-readable strings.