node-gcm icon indicating copy to clipboard operation
node-gcm copied to clipboard

Node GCM doesn't support Apple 'apns-collapse-id' or Android 'collapseKey'

Open jbruggeman opened this issue 7 years ago • 9 comments

Google has added 'apns-collapse-id' and 'collapseKey'. If you're using a non-legacy application it appears iOS 10+ devices will not be able to collapse notifications together.

See https://firebase.google.com/docs/cloud-messaging/concept-options

jbruggeman avatar Nov 16 '17 15:11 jbruggeman

Hi @jbruggeman, Thanks for the update!

The solution would be for node-gcm to support the new apns-collapse-id flag, right?

eladnava avatar Nov 16 '17 23:11 eladnava

@eladnava

So, looking into it a bit further, google now has two versions of the API. node-gcm looks like it covers the legacy API, but not the new API, which hits a different endpoint. This new API was released within the last month.

Do you think it makes sense to update node-gcm to handle a separate endpoint or perhaps a new wrapper library should be created?

jbruggeman avatar Nov 17 '17 17:11 jbruggeman

Hi @jbruggeman, That's interesting, can you please link to the article with the new API endpoint info?

It would probably make sense to update node-gcm as long as there are no breaking changes.

eladnava avatar Nov 18 '17 03:11 eladnava

@eladnava

The new API is described here: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send

The old API is listed as 'Legacy HTTP Server Protocol'.

jbruggeman avatar Nov 20 '17 15:11 jbruggeman

Hi @jbruggeman, Interesting, thanks for the links. 👍

Regarding collapse keys, node-gcm definitely supports those using the Legacy HTTP API parameter, see the README for syntax: https://github.com/ToothlessGear/node-gcm#additional-message-options

I think that updating node-gcm to hit the new FCM HTTP v1 API should only be done once there is functionality which is not available in the Legacy HTTP Server Protocol.

@hypesystem fyi

eladnava avatar Nov 23 '17 07:11 eladnava

I'm not quite sure I understand this correctly.

If it is true that there is no new functionality added (that there is no functionality current unsupported by node-gcm), I agree: we don't need to focus on a new version now.

If you are up for giving it a try, @jbruggeman, it might be cool to see how much would need to change in order to support the new API. I'm assuming that using the new API would still work for old applications, registering with the existing methods on the client side.

hypesystem avatar Nov 23 '17 12:11 hypesystem

@eladnava @hypesystem Yes, it has a collapseKey, but it will not generate the APNS apns-collapse-id in the resulting message, which is required for collapsing on iOS 10+. Adding this key is only available using the FCM HTTP v1 API.

So yes, there is new functionality added.

I did build a simple implementation wrapping the new API. I used the 'googleapis' package to do token management, and constructed the message according to the spec, and built a simple message queue to do message management.

I'll see what I can do about packaging it up into a releasable package.

jbruggeman avatar Nov 23 '17 15:11 jbruggeman

@jbruggeman Cool, if there is indeed missing functionality we may be forced to update to the new API sooner than later.

Is there any information on the Internet that references the fact that the old Legacy HTTP API does not set the apns-collapse-id flag when the collapse_key parameter is specified?

eladnava avatar Nov 24 '17 01:11 eladnava

A source for this would indeed be good, so we can document this current deficiency.

@jbruggeman do you have a subjective opinion on how much has changed between the API we use and the new one? I haven't had time to check it out, but it might be relevant to update what we do under the hood.

hypesystem avatar Nov 25 '17 12:11 hypesystem