延迟Google Cloud功能 [英] Delay Google Cloud Function

查看:71
本文介绍了延迟Google Cloud功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个快速的iPhone应用程序与Google Firebase配对.在应用程序内,用户将完成一个动作(按一个按钮).在这一点上,我想安排一个Google Firebase Function在用户操作后45分钟运行.但是,我希望在iPhone应用程序中完成另一项操作(按一个按钮)时可以取消此功能.我可以使用计时器迅速完成此操作,但是如果用户关闭应用程序,那将无法正常工作.

I have a swift iPhone application paired with Google Firebase. Within the application the user will complete an action (press a button). At this point, I would like to schedule a Google Firebase Function to run 45 minutes after the user action. However, I would like this function to be able to be cancelled when another action (press a button) is completed within the iPhone application. I could do this within swift with a timer but that wouldn't work if the user closes the application.

我不反对使用第三方调度程序或类似的程序.欢迎任何建议.

I am not opposed to using a third party scheduler or something of the sorts. Any suggestion welcome.

我研究了可能重复的问题和答案( Firebase的云函数)但是,该答案中的大多数链接已被弃用且已过时.同样,这是指重复安排某些事情.例如,每小时,每天一次等等,我希望在触发(用户操作)后45分钟安排该作业,并能够在该45分钟内取消该作业.

I have looked at the possible duplicate questions and answers (Cloud Functions for Firebase trigger on time?) However, most of the links in that answer are deprecated and out of date. Also, that is referring to scheduling something repeatedly. For example, every hour, once a day, etc... I am looking to schedule the job 45 minutes after trigger (user action) with the ability to cancel the job within that 45 minute window.

推荐答案

我最近遇到了一个类似的问题,该问题通过使用 Firestore .我设置了一个作业,该作业每5分钟触发一次云功能,该功能将检查Firestore集合.它将在何时触发云功能时检索数据并触发它.这也取决于您希望时间触发的精确度.无缘无故地一直触发它不是最佳选择,但就我而言,它确实有效.

I recently had a similar issue that was solved by using Cloud Scheduler and Firestore. I set up a job that would trigger a cloud function every 5 minutes that would check a Firestore collection. It would retrieve the data on when a cloud function should be triggered and trigger it. It also depends how accurate you want your time triggers to be. It's not optimal to have it trigger all the time for no reason but in my case it worked.

这篇关于延迟Google Cloud功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆