简体   繁体   中英

Firebase Cloud Function schedule to create document

We have a Flutter project with Firebase setup we would like to create a Firebase cloud function with node js that perform the following:

Every 27th of any month check the subscription date from the subscription collection. And create a new document in invoices collection then finally send an email & FCM with a payment URL.

For that you need to use a scheduled Cloud Function .

More precisely, you need to:

  • Schedule the Cloud Function as desired, for example with 0 0 27 * * , ie at 00:00 on day-of-month 27.
  • In the Cloud Function, query your Firestore collection for "checking the subscription dates"
  • In the Cloud Function, send an email. For example through the Trigger Email extension . it's actually just a matter of creating a doc in a Firestore collection, see this article for more details.
  • In the Cloud Function, send the FCM as explained here in the doc.

For the last 3 points, you need to use the Admin SDKs since you are coding in a Cloud Function. ( Doc for Firestore and doc for Messaging )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM