I've implemented something similar in an app I have. I use the Cloud Scheduler in Firebase and run it every 10 minutes.
When my user submits a message for a specific time, I record that time in the database (Realtime Database).
The cloud function launched by the cloud scheduler loops through that database, looking at the time the user has entered. If the time is within the last 10 minutes, then the message is sent and I remove the entry from that table.
To call the cloud function with the scheduler you create the function as follows:
exports.findScheduledEvents = functions.pubsub.topic('eventSchedule').onPublish(() => {
where eventSchedule is the name of my Cloud Schedule.
Firebase only charges you for the number of cloud schedules you have, not how often you run them. For me, very 10 minutes is sufficient, but you could run one every minute it you want. Just be careful not to make the table that is looped through too large. As I said, I remove the entry so that particular table never gets too big and it costs very little.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…