Skip to main content
Real-time listeners let you receive live events — messages, presence changes, group updates, and call signals — as they happen. The pattern is the same for all four listener types:
  1. Register a listener with a unique ID using addXListener()
  2. Handle events in the callback methods
  3. Remove the listener with removeXListener() when it’s no longer needed
Each listener ID must be unique. Re-registering with the same ID replaces the previous listener. Always remove listeners on component unmount to prevent memory leaks.
Always remove listeners when they’re no longer needed (e.g., on component unmount). Failing to remove listeners can cause memory leaks and duplicate event handling. For React Native, use useEffect cleanup functions to handle listener removal automatically.
CometChat provides 4 listeners viz.
  1. User Listener
  2. Group Listener
  3. Message Listener
  4. Call Listener

User Listener

Receive online/offline presence events for users. To add the UserListener:
Remove the listener when no longer needed:

Group Listener

Receive events when group members join, leave, are kicked/banned, or have their scope changed. To add the GroupListener:
Remove the listener when no longer needed:

Message Listener

Receive events for incoming messages, typing indicators, read/delivery receipts, message edits/deletes, reactions, and interactive messages. To add the MessageListener:
Remove the listener when no longer needed:

Call Listener

Receive events for incoming and outgoing call state changes. To add the CallListener:
Remove the listener when no longer needed:

Next Steps

User Presence

Track when users come online or go offline

Receive Messages

Handle incoming messages in real time

Typing Indicators

Show when users are typing

Connection Status

Monitor SDK connection state changes