Has anyone created a presence system with appgyver and Firestore?

I would like to attempt to create a presence system so users will be able to show their status as online or offline, but am trying to figure out the best way to sync the status change when a user closes the connection. The typical firebase docs do not really apply as they are all for the native sdks. I guess the big question would be how to make a quick write to database just before the app closes when a user closes the app or becomes inactive. Has anyone been able to do this?

you can use the realtime database from firebase, where you can change automatically a value, every 5 sec and on the other side, check to see if that value changes, of course, when the value stops changing, means that the app is closed.

1 Like

I also found this one using functions but i think is totally doable with just realtime
https://firebase.google.com/docs/firestore/solutions/presence

I am aware of all the firebase docs and typical methods. It seems like it would be better if there was a way to write a value on login or app opened, then write a value on app closed or destroyed.

1 Like

unfortunately, you cant trigger event on app closed, only on app launched but even that, doesn’t mean that the app opened, is only when the app launches.

Wouldn’t there be some way to use the application by shutting down? (like with the Mounting)

2 Likes

There is a “Page will unmount” event you can receive on your first/initial page that will indicate the app is closing. In that event you can write to your database that the app is closing.

2 Likes

Nice to learn that! …

1 Like

Edit that: Its “Page will unmount”

2 Likes