Custom push notification on document change using cloud functions

Custom Code

I'm looking for a way to send out push notifications when a document in an FB collection changes.

The current cloud function FlutterFlow is using is triggered by adding a document to a collection called ff_push_notifications. This is ok when there are not that many push notifications to send to users.

My app has a chat function which usually means that for every message a push notification is triggered. So, on top of every new document create (new message document) and document updated (chat document) that occurs, an extra document is created for the push notification and read to get the fcm-token.

A solution for the first part of the problem would be to trigger a notification on change of the β€œchat” document and use the content from this document to send a push notification without creating a separate ff_push_notifications document.

A solution for the second part of the issue would be to store the fcm-token in a page state in order to not read the document every time a new message is sent. I don't know how to access this.

Does anyone know how to trigger a push notification from a document update using cloud function and how to get the fcm-token in a page stage

What have you tried so far?

I've already checked all the existing community questions but could find a solution.

Did you check FlutterFlow's Documentation for this topic?
Yes
1
5 replies