Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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:
| Method | Description |
|---|---|
subscribePresenceForAllUsers() | Receive presence updates for all users |
subscribePresenceForRoles(List<String> roles) | Receive presence updates only for users with specified roles |
subscribePresenceForFriends() | Receive presence updates only for friends |
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
| Parameter | Description |
|---|---|
listenerID | An ID that uniquely identifies that listener. We recommend using the activity or fragment name. |
UserListener Events
| Event | Description |
|---|---|
onUserOnline(User user) | Triggered when a subscribed user comes online |
onUserOffline(User user) | Triggered when a subscribed user goes offline |
User object with presence information.
Relevant fields to access on returned users:
| Field | Type | Description |
|---|---|---|
status | String | Online status of the user ("online" or "offline") |
lastActiveAt | int | Timestamp when the user was last active |
- 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