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:
Pin and unpin are conversation-wide — every participant receives them. Save and unsave are private multi-device: they reach the saving user’s other sessions, not the device that performed the save, which already has the message resolved from the saveMessage() promise. Each callback carries the full updated message, so getPinnedAt() / getSavedAt() are readable without a further fetch. See Pin A Message and Save A Message.
Conversation pins have no listener. The React Native SDK exposes no ConversationListener and no onConversationPinned / onConversationUnpinned callbacks — unlike the JavaScript SDK. Update your list from the pinConversation() promise and re-fetch on focus. See Pin A Conversation.

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