Skip to main content
Reactions let users respond to messages with emoji. You can add or remove reactions, fetch all reactions on a message, listen for reaction events in real time, and update your UI when reactions change. Reactions work on text messages, media messages, and custom messages.

Add a Reaction

Call addReaction() with a message ID and an emoji string.

Remove a Reaction

Call removeReaction() with the same message ID and emoji.
Both addReaction() and removeReaction() return a BaseMessage object with the updated reactions.

Read Reaction Data from a Message

Any BaseMessage exposes reaction data through two methods:

Get All Reactions

Use getReactions() to retrieve the list of reactions on a message. Returns an array of ReactionCount objects, or an empty array if no one has reacted.

Check if the Logged-in User Has Reacted

Call getReactedByMe() on any ReactionCount object to check whether the logged-in user has reacted with that particular emoji. Returns true if they have, false otherwise.

Fetch Reactions for a Message

To get the full list of who reacted with what on a specific message, use ReactionsRequestBuilder. You can paginate through results with fetchNext() and fetchPrevious() (default 10, maximum 1000 per request). A larger limit is sent as 1000.

Fetch Next

Fetch Previous

Offline Behaviour

With offline support enabled, ReactionsRequest.fetchNext() and fetchPrevious() first deliver onCachedReactions from the device when you pass a ReactionFetchListener (empty when nothing was recorded), then onServerReactions with the live page to reconcile by reaction id. Use a separate ReactionsRequest for each direction. Offline, a read ends with onError with code FAILED_TO_FETCH after the cached page. The cached phase replays the page this request last received from the server online, in the same direction. It does not re-run these settings as a query against the cache.

Real-Time Reaction Events

Register a MessageListener to receive reaction events as they happen. This is how you keep your UI in sync when other users add or remove reactions. Override onMessageReactionAdded and onMessageReactionRemoved. Each receives a ReactionEvent, whose getReaction() returns the Reaction and whose getReceiverId(), getReceiverType(), getConversationId() and getParentMessageId() identify where it happened.

Remove the Listener

Remove the listener with the same listener ID:
Always remove listeners when they’re no longer needed (e.g., on component unmount or screen navigation). In React Native, place this in a cleanup function inside useEffect or in componentWillUnmount. Failing to remove listeners can cause memory leaks and duplicate event handling.

Update Message With Reaction Info

When a user adds or removes a reaction, you will receive a real-time event. Once you receive it, you would want to update the message with the latest reaction information. To do so, use CometChat.CometChatHelper.updateMessageWithReactionInfo(). Pass the BaseMessage the reaction belongs to, the Reaction from the event (reactionEvent.getReaction()), and the action: CometChat.REACTION_ACTION.REACTION_ADDED from onMessageReactionAdded or CometChat.REACTION_ACTION.REACTION_REMOVED from onMessageReactionRemoved. It returns the message with its getReactions() updated.
On success, this method returns a BaseMessage object. After calling this method, use modifiedBaseMessage.getReactions() to get the latest reactions and refresh your UI.

Next Steps

Send Messages

Send text, media, and custom messages to users and groups

Receive Messages

Listen for incoming messages in real-time and fetch missed messages

Mentions

Mention specific users in messages

Threaded Messages

Organize conversations with message threads