AI Integration Quick Reference
AI Integration Quick Reference
Real-time Presence
In other words, as a logged-in user, how do I know if a user is online or offline? Configure presence subscription inAppSettings during SDK initialization. The AppSettingsBuilder provides three subscription options:
If none of these methods are called, no presence events will be delivered.
You must configure presence subscription in
AppSettings during CometChat.init() before any presence events will be delivered. See Setup SDK for details.UserListener to receive presence events. We suggest adding the listener in the init method of the activity or the fragment where you wish to receive these events in.
- Dart
UserListener Events
Each callback receives a
User object with presence information.
Relevant fields to access on returned users:
Remove the listener when no longer needed:
- Dart
User List Presence
In other words, as a logged-in user, when I retrieve the user list, how do I know if a user is online/offline? When you retrieve the list of users, in the User object, you will receive 2 keys:status- This will hold either of the two values :
online- This indicates that the user is currently online and available to chat.offline- This indicates that the user is currently offline and is not available to chat.
lastActiveAt- In case the user is offline, this field holds the timestamp of the time when the user was last online. This can be used to display a Last seen for that user.
Next Steps
Retrieve Users
Fetch user lists with filtering and pagination
User Management
Create and update users programmatically
Connection Status
Monitor SDK connection to CometChat servers
Block Users
Block and unblock users in your app