简体   繁体   English

Firebase 云 Function 计划创建文档

[英]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: 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.每个月的 27 日从订阅集合中检查订阅日期。 And create a new document in invoices collection then finally send an email & FCM with a payment URL.并在发票集合中创建一个新文档,然后最终发送 email 和 FCM 以及付款 URL。

For that you need to use a scheduled Cloud Function .为此,您需要使用 预定的云 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.根据需要安排云 Function,例如使用0 0 27 * * ,即在每月 27 日的 00:00。
  • In the Cloud Function, query your Firestore collection for "checking the subscription dates"在 Cloud Function 中,查询您的 Firestore 集合以获取“检查订阅日期”
  • In the Cloud Function, send an email.在云 Function 中,发送 email。 For example through the Trigger Email extension .例如通过触发 Email 扩展 it's actually just a matter of creating a doc in a Firestore collection, see this article for more details.这实际上只是在 Firestore 集合中创建一个文档的问题,有关更多详细信息,请参阅本文
  • In the Cloud Function, send the FCM as explained here in the doc.在云 Function 中,按照文档中的 说明发送 FCM。

For the last 3 points, you need to use the Admin SDKs since you are coding in a Cloud Function.对于最后 3 点,您需要使用 Admin SDK,因为您在 Cloud Function 中进行编码。 ( Doc for Firestore and doc for Messaging ) Firestore 文档和消息传递文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何安排 Firebase Cloud function 在创建后的特定 firestore 文档上运行 5 分钟 - how to schedule a Firebase Cloud function to run in 5 minutes on a specific firestore document upon creation 您是否需要创建一个单独的集合/文档来读取带有 firebase 云 function 的聚合文档 - do you need to create a separate collection/document for reading an aggregated document with firebase cloud function 创建一个 firebase 云 function 检测 emailVerified 变化 - Create a firebase cloud function that detects emailVerified change Firestore接管一分钟搞定里面的文档 Firebase Cloud Function - Firestore take over a minute to get a document inside Firebase Cloud Function 在 firebase 云函数 flutter 中发送计划 email - Send schedule email in firebase cloud functions flutter 部署 firebase 云函数时创建函数项目失败 - Failed to create function project when deploying firebase cloud function Firebase 创建文档并递增 - Firebase create a document and increment Firebase 云 function 未触发 - Firebase cloud function not triggered 如何使用 Firebase Cloud Messaging 安排本地推送通知? - How do I schedule a local push notification with Firebase Cloud Messaging? Firebase 云 function 时间戳 - Firebase cloud function timestamp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM