Firebase Functions - Iterate Entries And Send Notification For Certain Conditions
Solution 1:
You will find hereafter links to tutorials or code examples covering your needs :
1/To call a Cloud Function regularly, you have to trigger it via http through a cron-job.
https://firebase.google.com/docs/functions/http-events).
and
https://www.youtube.com/watch?v=CbE2PzvAMxA
2/ For sending a notification:
https://firebase.google.com/docs/functions/use-cases#notify_users_when_something_interesting_happens
https://github.com/firebase/functions-samples/blob/master/developer-motivator/functions/index.js
https://android.jlelse.eu/serverless-notifications-with-cloud-functions-for-firebase-685d7c327cd4
PS: an extra advice : you should better store your dates as one String if possible. The best option being to convert your date to the number of milliseconds since January 1, 1970, 00:00:00 GMT
Solution 2:
My team faced a similar situation and we made use of a simple setInterval at index.js.
Have a callback that does the notificiation function.
Also agree to Renaud's point of making use of a better timestamp. We made use of firebase.database.ServerValue.TIMESTAMP as this will take the server time and not the local time of the user. Hope it helps. ATB.
https://firebase.google.com/docs/reference/js/firebase.database.ServerValue
Post a Comment for "Firebase Functions - Iterate Entries And Send Notification For Certain Conditions"