decision-labs / fcm

Ruby bindings to Firebase Cloud Messaging (FCM) for Android, iOS or Web
MIT License
510 stars 153 forks source link

Support for sending batches of messages in API/v1 #114

Open gersonazgo opened 1 year ago

gersonazgo commented 1 year ago

Feature Request

Is your feature request related to a problem? Please describe. I'm using the 'fcm' gem in my Rails project to send my push notifications via Firebase. The problem I'm encountering is that the gem does not currently support batch messages (API/v1, the legacy works perfect). This means that I have to send each message individually, which is quite inefficient

Describe the solution you'd like According to the Firebase Documentation, the REST API and Admin SDKs support sending messages in batches of up to 500 messages. This feature allows developers to group messages together and send them in a single API call, providing significant performance improvement over sending individual HTTP requests for each message.

Describe alternatives you've considered Without this feature, I'm forced to loop through each message and send it individually or build the batch logic myself — which I think should belong in this gem.

Thank you for your consideration.

flivni commented 1 year ago

I'd like batch support as well. Any plans to implement?

If not, would you accept a PR that adds? For now, either:

Option (a) add a method called send_all_v1(messages) Option (b) allow send_v1(...) to take either an individual message or an array of messages.

JerakRus commented 9 months ago

It seems to me that the problem is not entirely relevant, this API will soon be deleted from Google and it will be necessary to think about how to switch to supporting a new one. https://firebase.google.com/support/faq?hl=ru#fcm-23-deprecation. If I understood everything correctly of course.

AllanKlaus commented 1 month ago

It seems to me that the problem is not entirely relevant, this API will soon be deleted from Google and it will be necessary to think about how to switch to supporting a new one. https://firebase.google.com/support/faq?hl=ru#fcm-23-deprecation. If I understood everything correctly of course.

The gem already support the new standard the format that will be deprecated will be the send thought POST https://fcm.googleapis.com/fcm/send and the API already implements the new request POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send. https://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=pt-br#update-the-server-endpoint

you can check on code https://github.com/decision-labs/fcm/blob/master/lib/fcm.rb#L8

So we still need this implementation to send in batches

JerakRus commented 2 weeks ago

@sabman Hello, I see that you have closed the issue, but I do not see any changes in the functionality of the library over the past year?