Open ZeWaren opened 7 years ago
FCM notification messages seem to be the same as GCM notification messages. See https://developers.google.com/cloud-messaging/concept-options#notifications_and_data_messages
Doing this in a way that provides a consistent and easy to use API for GCM/FCM and APNS may require some thought, so this fully doing this may or may not be time consuming. (GCM "data" doesn't seem to have special fields, and I haven't yet checked if APNS would have special fields
A good first step would be to support uniqush.data.gcm
and uniqush.data.fcm
in API calls to /push
, which would be similar to uniqush.payload.gcm
(name to be determined. uniqush.silent_notification.gcm
? uniqush.silent_notification.cloud_messaging
?). See https://github.com/uniqush/uniqush-push/blob/317b0884f85080d67da73cb7b8a99551bc02c40a/srv/gcm_test.go#L39-L43
My earlier comment mixed those up. Supported fields are https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support
Currently, client apps work around this by creating a notification handler to render the notifications programmatically based on the data.
In the future, it may make sense to change how uniqush handles msg
, etc, to be more consistent (e.g. uniqush.version=2 in /push and/or the config). The consistent way would be rendering immediately.
The support for uniqush.notification.gcm
and uniqush.notification.fcm
(optional fields for /push with rawJSON blobs as values) are documented at https://github.com/uniqush/uniqush-push/pull/185.
Those are merged to master. I'll spot check them before updating the go1
tags and publishing a 2.4.0 release to github.
It isn't documented on uniqush.org yet, I haven't written the changes to uniqush-www yet.
I've built the version and tried it.
The first tests indicate that it's working well. Good job!
We're going to use it in production in the next few days.
I'll let you know if we find any issue. Reading the code, I don't think we will.
FCM allows sending "notification messages" and "data messages". These two types of message behave differently when received by a device.
See: Firebase documentation -> Guides -> Cloud Messaging -> About FCM Messages -> Message types (https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages)
Uniqush should be able to send both types. Right now, only data messages are sent (See function ToCMPayload in https://github.com/uniqush/uniqush-push/blob/master/srv/cloud_messaging/cloud_messaging.go#L165)
Also, it's possible to send hybrid push messages, containing both data and notification information.
=> Add some parameters to
/push
to handle all types.