Sennen Randika
Sennen Randika

Reputation: 1636

How to run a background Cloud Function and schedule a change in database?

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?

Upvotes: 4

Views: 2321

Answers (1)

Related Questions