I want the data sent by the user to arrive in the firebase realtime database after 10 minutes. Is there a shortcut to this? My current method is very costly. In the method I'm using now, I'm sending it to the server first. After waiting 10 minutes on the server, I send it to Firebase Realtime Database. Is there a way to do this directly?
2 Answers
Apparently, you also want the data to be written after 10 minutes even if the user closes the application before the data is written.
The only way you can achieve this is to set up a second server.
Your application writes the data to the second server with the instructions to send it to the Firebase database after 10 minutes.
The second server sets up a scheduled task (or something) to write the data to Firebase after the 10 minute delay.
To make this reliable, the second server needs a database to store the requests, in case it crashes and restarts while there are pending write requests to send. Then when it restarts, it needs to scan its table for any requests that should have been sent, and send them.
On re-reading your question, it seems like that may be what you have already implemented. (Albeit that you don't mention the crash and recover issue.)
This is all rather strange and complicated, which leads me to wonder if this is an example of the XY Problem. Couldn't you just write the data to Firebase immediately, and add an extra attribute to the data to say when it becomes active?

- 698,415
- 94
- 811
- 1,216
There is no functionality built into the Firebase Realtime Database to send time-delayed writes to the server. The only similar functionality is onDisconnect
, which sends a write to the database that get executed when the server detects that the client has disconnected. But there is no time-delay on this write operation.
Since this functionality is not built into Firebase, you'll have to build it yourself. Having custom server-side code (or Cloud Functions) that handles the time-delayed write is the simplest approach I can think of for that.

- 565,676
- 79
- 828
- 807