MihaelIsaev / FCM

⚡️ PushNotifications through FireBase for Vapor 3 and 4.
MIT License
120 stars 33 forks source link

Alternative approach to sending to multiple devices #29

Closed siemensikkema closed 3 years ago

siemensikkema commented 3 years ago

@MihaelIsaev it appears that the approach you took for sending messages to multiple devices is to create a topic for each group of 20 recipients, then for each topic send the message and delete the topic afterwards. Although it works, it seems a bit fragile and suboptimal. Firebase accepts sending messages to up to 500 recipients at a time using a "mixed/multipart" request to https://fcm.googleapis.com/batch: https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices

Have you experimented with that?

MihaelIsaev commented 3 years ago

is to create a topic for each group of 20 recipients

it looks like there are no limitation for topic devices amount in docs, but I choose 20 just in case. It was better than send request per each token.

Firebase accepts sending messages to up to 500 recipients at a time using a "mixed/multipart" request to https://fcm.googleapis.com/batch: https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices

Wow, thank you @siemensikkema for the information! I could bet that I read all the docs 100 times by myself and also some people tried to help me with that and no one seen this endpoint before. But webarchive says that it was there since April 1st 2019! That's unbelievable! 🤪 Sure we should use that awesome endpoint for sending multiple messages then.

I could implement it this or maybe next week. Or let me know if you would like to send pull request 🙂

siemensikkema commented 3 years ago

@MihaelIsaev great! Glad my googling can be of help to you 😊 I don't think I'll have time to implement it myself soon but I can help out reviewing. So feel free to tag me when you get around to implementing it!

siemensikkema commented 3 years ago

@MihaelIsaev did you manage to take a look at this? Is it a large undertaking you think? It seems to require a slightly different approach to contacting Firebase.