ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 206 forks source link

Firebase Legacy HTTP API discontinued by June 20, 2024 #370

Open sjkummer opened 1 year ago

sjkummer commented 1 year ago

Hey @eladnava

Google informed that the "Legacy HTTP" API used by this library will be discontinued by June 20, 2024.

This library has not been updated for a while. Do you plan to implement the new API or would you recommend to switch to Googles FCM Admin lib? https://www.npmjs.com/package/firebase-admin

Migration Guide: https://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=en

Best regards and thanks for maintaining all the years.

mtrezza commented 1 year ago

Would you want to open a PR?

eladnava commented 1 year ago

Hi @sjkummer, For the time being, I would recommend switching to the official firebase-admin package published by Google. Migrating node-gcm to the new API will require a complete library rewrite, as the code design is very tightly coupled with the Legacy HTTP API currently.

If anyone has any bandwidth to perform the migration, they are welcome to submit a PR.

eladnava commented 1 year ago

Hi @sjkummer, I've just released fcm-v1-http2, a Node.js package for sending multicast notifications using HTTP/2 multiplexing through the FCM HTTP v1 API, in case you need to send notifications to a large number of device tokens. Otherwise, I recommend using the official firebase-admin library.

sjkummer commented 1 year ago

Thanks for the clarifications and feedback.

I justed dived a bit deeper into the firebase-admin lib

@eladnava Batched mutlicast should already be possible using firebase-admin too, using sendeachformulticast() right? https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging?hl=en#messagingsendeachformulticast

But it seems like the more efficient sendall method (which executes only one RPC call instead multiple) is deprecated 🤔 is this was prevented you from using firebase-admin in your case?

https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md?hl=en#messagingsendall

eladnava commented 1 year ago

Hi @sjkummer, I was surprised to discover that the official Firebase Admin Node.js SDK had been updated to include a new method sendEachForMulticast(), and developers are urged to migrate to using it instead of the now deprecated sendMulticast(). However, if you were to use this method with any large number of device tokens, your server might crash or grind to a halt, as the Firebase Admin SDK opens a new HTTP 1.0 connection for every single device token simultaneously.

That's correct - using any of the batch methods is deprecated, as Firebase also deprecated the batch API endpoints (which sendAll() and sendMulticast() rely on). The only viable alternative is HTTP/2 multiplexing for multicast notifications at scale.

I just published a blog post about this. Please give it a read and let me know what you think.

DaveLomber commented 1 year ago

@sjkummer @mtrezza just wondering is it something you may be interested in https://github.com/appfeel/node-pushnotifications/pull/194

siakc commented 11 months ago

Does this issue render this package obsolete?

eladnava commented 11 months ago

Hi @siakc, That's correct.

Migrating node-gcm to use the new HTTP v1 API over HTTP/2 will require a complete rewrite of the package, as the code design is very tightly coupled with the Legacy HTTP API currently.

That means node-gcm will indeed stop working on June 20, 2024 unless it gets migrated.

If anyone has any bandwidth to perform the migration, they are welcome to submit a PR.

In the meantime, I have released a package called fcm-v1-http2, which uses the new FCM HTTP v1 API to send notifications using HTTP/2 multiplexing. You are also welcome to use the official firebase-admin library if throughout isn't important, or you do not intend to send notifications to a large number of recipients at once.

ArmandoLinnkr commented 11 months ago

How about https://github.com/appfeel/node-pushnotifications/pull/194 though? It is supposed to add the new FCM method, no?

eladnava commented 11 months ago

@ArmandoLinnkr That Node.js library uses firebase-admin's sendEachForMulticast() method behind the scenes to send notifications using the HTTP v1 API. So you can either use that library, or use firebase-admin directly, or use my own ibrary fcm-v1-http2 if you intend to send time-sensitive notifications to a large number of recipients.

iamromec commented 5 months ago

Any update on this? We're so close to the deadline. Please update.

@ToothlessGear

eladnava commented 5 months ago

Unfortunately @ToothlessGear hasn't been active in a while.

We do urge you to migrate to another library before the June 20th deadline, such as:

  1. firebase-admin (official library)
  2. fcm-v1-http2 (if throughput is important to your sending requirements)

This is now mentioned in the package README.