【问题标题】:Cron Job in FirebaseFirebase 中的 Cron 作业
【发布时间】:2019-03-14 20:41:29
【问题描述】:

如何在 firebase 实时数据库中创建 cron 作业,我有一个适用于 android 的应用程序并且该应用程序有奖励,当用户在后端获得奖励时,我将 bool var Gift 更新为 true,他用户可以仅当礼物为假时才获得奖励,然后当他获得奖励时礼物更改为真,我需要一个 cron 作业来每天重置此变量,您能帮帮我吗? PD:我正在与统一的 android 游戏和 firebase 实时数据库一起工作到后端

【问题讨论】:

  • 无法在数据库中运行代码。正如 SnorreDan 回答的那样,最简单的方法是使用 Cloud Functions 并使用此处提到的其他选项之一的 Cloud scheduler 对其进行调度:stackoverflow.com/questions/42790735/…

标签: firebase unity3d cron-task


【解决方案1】:

您可以使用 Firebase 云函数 https://firebase.google.com/docs/functions/http-events 创建一个 HTTP 函数。该函数将访问实时数据库并将 Gift 变量设置为 false。

那么用GCP Cloud schedulerhttps://cloud.google.com/scheduler/每天调用一次这个函数就很简单了。

【讨论】:

    猜你喜欢
    • 2019-03-09
    • 2016-06-14
    • 2011-11-11
    • 2012-05-11
    • 2013-08-29
    • 2014-08-31
    • 2014-11-23
    • 1970-01-01
    相关资源
    最近更新 更多