Start a new topic

List all users online

I'm creating a simple demo app where I'd like to show in a list all the users that are currently online. The list should update automatically when new users visit the app and when they leave.

Is this possible with Kinvey?
1 Comment

The general principle of implementing such a functionality is to maintain a `lastActive` property on the user object. In your app, periodically (let’s say every 5 minutes), update this property with the current date.

To get the list of currently online users (or, more precise, the users active in the last 5 minutes), just query on `lastActive >= now -5 minutes`. You can execute this query every now and then so you can update the UI accordingly.
Login or Signup to post a comment