事件发生后一分钟如何执行Firebase Cloud功能?

我正在为我的Android应用程序使用Firebase实时数据库。我想在数据库写入发生后1分钟执行firebase函数(不是像Cron作业那样每1分钟后执行一次)。可能吗?如果可能的话我该怎么办?

sgflh 回答:事件发生后一分钟如何执行Firebase Cloud功能?

Cloud Functions不提供延迟的调用,但是您可以与Cloud Tasks集成,以在延迟一段时间后安排对另一个函数的回调。

,

这是一个变通方法,如果您想延迟相当长的时间,请考虑注意云函数超时选项,如果需要,请增加它,默认超时是在函数第一次开始执行的 60 秒之后

export const {Your function Name} = functions
  .runWith({ timeoutSeconds: 120 }) // set the timeout in second,(the type is number)
  .https.onRequest(async (req,res) => {}

你可以把所有你想延迟的东西都包在一个

setTimeout(() => { // your code inside the functions you want it to be delayed },delay time in seconds) 函数

本文链接:https://www.f2er.com/3169057.html

大家都在问