3

I'm developing an app using React Native and Firebase Realtime database. I want to do something like this.

From the app, I set a time duration and press a button. Then, it writes data to the Firebase. Assume that I set the time duration to 1000000000 ms and press the button. Then, the database looks like this:

schedules
  |
  |--schedule1
       |
       |--status: "Running"
       |--durationInMS: 1000000000

I want to run a background function that changes the above status to "TimeOver" after 1000000000 ms. This function should be run in the background even if the app is closed:

schedules
      |
      |--schedule1
           |
           |--status: "TimeOver"
           |--durationInMS: 1000000000

How to do this?

tzovourn
  • 1,293
  • 8
  • 18
Sennen Randika
  • 1,566
  • 3
  • 14
  • 34

1 Answers1

3

There is no built-in trigger to run after a certain delay that is written in the database.

But you can either build your own scheduler using Cloud Scheduler, or create a regularly running scheduled function that then checks for expired schedules in your database.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807