Skip to main content
CometChat provides these real-time listeners:
  1. UserListener
  2. GroupListener
  3. MessageListener
  4. ConversationListener
  5. AIAssistantListener
  6. CallListener
With offline support enabled, four more listeners report what the SDK does on the device; see Offline listeners.

User Listener

The UserListener class provides you with live events related to users. Below are the callback methods provided by the UserListener class. To add the UserListener, you need to use the addUserListener() method provided by the CometChat class.
where UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. Once the activity/fragment where the UserListener is declared is not in use, you need to remove the listener using the removeUserListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.

Group Listener

The GroupListener class provides you with all the real-time events related to groups. Below are the callback methods provided by the GroupListener class. To add the GroupListener, you need to use the addGroupListener() method provided by the CometChat class.
where UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. Once the activity/fragment where the GroupListener is declared is not in use, you need to remove the listener using the removeGroupListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.

Message Listener

The MessageListener class provides you with live events related to messages. Below are the callback methods provided by the MessageListener class.
With offline support enabled, MessageListener also receives onMessagesSynced after the SDK catches up on reconnect. It carries updates to already-cached messages that changed while offline (reactions, edits, deletes and receipts); messages that arrived while offline still come through the typed callbacks such as onTextMessageReceived. See Stay in Sync.
To add the MessageListener, you need to use the addMessageListener() method provided by the CometChat class.
where UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. Once the activity/fragment where the MessageListener is declared is not in use, you need to remove the listener using the removeMessageListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.

Conversation Listener

The ConversationListener class provides you with live events related to conversations. Below are the callback methods provided by the ConversationListener class. To add the ConversationListener, you need to use the addConversationListener() method provided by the CometChat class.
Once you have successfully registered the listener and no longer wish to receive any events, you need to remove the listener using the removeConversationListener() method with the same UNIQUE_LISTENER_ID.
There is no thread listener. Thread replies are ordinary messages carrying a parent message ID, so they arrive on the MessageListener callbacks above, and a subscribeToThread() / unsubscribeFromThread() callback is the acknowledgement of a subscription change. See Thread Subscription.

AI Assistant Listener

The AIAssistantListener class provides you with real-time streaming events from AI Agent runs. These events are emitted during a run lifecycle and include tool calls, card generation, and text message streaming. For a complete overview of the event lifecycle, see AI Agents. To add the AIAssistantListener, use the addAIAssistantListener() method provided by the CometChat class.
The AIAssistantListener delivers real-time streaming events. After a run completes, persisted agentic messages (AIAssistantMessage, AIToolResultMessage, AIToolArgumentMessage) are delivered via the MessageListener callbacks listed above.

Call Listener

Superseded. CallListener and addCallListener() are no longer the way calls announce themselves, and a coming Chat SDK release marks them deprecated together with the Chat SDK’s other calling methods. Calls now ring through the Push Notifications SDK and announce themselves on the Calls SDK’s CometChatCalls.addIncomingCallListener (onIncomingCallReceived, onIncomingCallEnded(call, reason)), whether the call arrived by push on a killed process or while the app was running. The caller’s “answered” event is ParticipantEventListener.onParticipantJoined on the prepared session. See Ringing and Migrating from Legacy Ringing. The section below is kept for apps still on the legacy flow.
The CallListener class provides you with live events related to calls. Below are the callback methods provided by the CallListener class. To add the CallListener, you need to use the addCallListener() method provided by the CometChat class.
Where UNIQUE_LISTENER_ID is the unique identifier for the listener. Make sure that no two listeners are added with the same listener ID as this could lead to unexpected behavior resulting in loss of events. Once the activity/fragment where the MessageListener is declared is not in use, you need to remove the listener using the removeMessageListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.

Offline listeners

With offline support enabled (SDK 5.1.0+), these listeners report what the SDK does on the device rather than events from the server. Each is documented with examples on its own page.