1

How can I create a cron job in firebase real time database, i have an application for android and the app has a reward , whe the user get a reward in the backend i update a bool var Gift to true and he user can get the reward only if the Gift is false then when he get the reward the Gift change to true and i need a cron job for reset this variable every day, can you help me ? PD: i am working with unity for the android game and firebase real time database to the backend

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Bryansq2nt
  • 394
  • 6
  • 16
  • There is no way to run code in a database. As SnorreDan answered, the simplest approach is using Cloud Functions and scheduling them with Cloud scheduler of one of the other options mentioned here: https://stackoverflow.com/questions/42790735/cloud-functions-for-firebase-trigger-on-time – Frank van Puffelen Mar 15 '19 at 04:07

1 Answers1

1

You could create an HTTP function with firebase cloud functions https://firebase.google.com/docs/functions/http-events. This function would access the real time database and set the Gift variable to false.

Then it is very easy to call this function once every day with GCP Cloud scheduler https://cloud.google.com/scheduler/.

SnorreDan
  • 2,740
  • 1
  • 14
  • 17