I'm working on an app where the user creates a party where people can join, and all parties are stored in a Firestore collection as documents.
What I want to do is that when the user leaves the app after creating a party, he gets 5m, after 5m the party he created gets deleted from the cloud firestore.
So basically, I want to remove the inactive firestore documents(parties) as soon as possible.
I tried to make a timer, when he doesn't kill the app, the timer works well and deletes the document after 5m.
The problem is that when he kills the app, the app obviously stops, so does the timer, which prevents me from deleting his party. What should I do? Is there a way to make the timer keeps ticking even after killing the app?
The timer is just a solution I thought of to delete the abandoned parties, other suggestions are welcomed.
I tried to make an explicit broadcast which is triggered in onStop, and I start the timer in onRecieve, but onRecieve stops when the app is killed, to make it run when the app is killed I need to trigger it after the app is killed, but I don't know how to do this.
Note: Solutions other than cloud functions are preferable. But if there is no other way please inform me.
question from:
https://stackoverflow.com/questions/65838006/deleting-abandoned-firestore-documents-by-keeping-a-timer-running-after-the-app 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…