jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

Multiple recipients, same message, different data payloads #40

Closed gask closed 5 years ago

gask commented 5 years ago

Hi there, I've been using fcm-node in my nodejs app for a while now and it's been great. But there are some cases where I have my doubts on how to proceed: I have some cases where I need to send a certain type of notification with user-specific payloads but with the same push notification message. The approach I've been using nowadays is, IMHO inefficient and I'd like to share it with you and ask if there is a way of doing this in a better way.

I'm currently creating separate notifications and sending each one with the same message, but different payloads (aka ids of one of my classes, so that the client knows how to react to the notifications when they open it). So if I have lotsof this messages, my server ends up iterating them all, which I find mostly inefficient.

I work as well with mandril-api and they have a great approach to send bulk emails with the same template, but different payloads and that's what I've been searching to do with fcm-node, to no success. Can someone help me with the reason why there is no such feature, or if there is, which feature I can use to send bulk notifications with the same message, but different data payloads?

Thanks in advance!

jlcvp commented 5 years ago

Unfortunatelly, Firebase doesn`t have support for an approach like yours.

If there's a bottleneck on server because of this, I'd move to a push-then-pull approach, where you send the same notification to the users and then make a request, once the notification is clicked, the server is responsible to identify each user and serve the appropriate data they need, thus reducing the peak usage on server and spreading the load through time