Skip to main content

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.

FieldValue
Key ClassesBaseMessage, Reaction, ReactionCount, ReactionEvent, ReactionsRequest, ReactionsRequestBuilder
Key MethodsCometChat.addReaction(), CometChat.removeReaction(), ReactionsRequest.fetchNext(), ReactionsRequest.fetchPrevious(), CometChatHelper.updateMessageWithReactionInfo()
Listener EventsonMessageReactionAdded, onMessageReactionRemoved
PrerequisitesSDK initialized, user logged in
// Add a reaction to a message
CometChat.addReaction(messageId, "\U0001f600", onSuccess: (message) {
  debugPrint("Reaction added: ${message.getReactions().last}");
}, onError: (e) {});

// Remove a reaction from a message
CometChat.removeReaction(messageId, "\U0001f600", onSuccess: (message) {
  debugPrint("Reaction removed");
}, onError: (e) {});

// Fetch reactions for a message
ReactionsRequest request = (ReactionsRequestBuilder()
  ..messageId = messageId
  ..limit = 30
).build();
request.fetchNext(onSuccess: (reactions) {}, onError: (e) {});

// Listen for reaction events
CometChat.addMessageListener("LISTENER_ID", MessageListener(
  onMessageReactionAdded: (ReactionEvent event) {},
  onMessageReactionRemoved: (ReactionEvent event) {},
));
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.
Available via: SDK | REST API | UI Kits

Add a Reaction

Call addReaction() with a message ID and an emoji string.
ParameterTypeDescription
messageIdintThe ID of the message to react to.
reactionStringThe reaction emoji (e.g., "\U0001f600", "\U0001f44d").
int messageId = 1;

CometChat.addReaction(messageId, "\U0001f634", onSuccess: (message) {
  debugPrint("Success : ${message.getReactions().last}");
}, onError: (e) {
  debugPrint("Error: ${e.message}");
});   
On Success — A BaseMessage object representing the message with the reaction added:BaseMessage Object:
ParameterTypeDescriptionSample Value
idnumberUnique message ID401
metadataobjectCustom metadata attached to the message{}
receiverobjectReceiver user objectSee below \u2193
editedBystringUID of the user who edited the messagenull
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
sentAtnumberEpoch timestamp when the message was sent1745554729
receiverUidstringUID of the receiver"cometchat-uid-2"
typestringType of the message"text"
readAtnumberEpoch timestamp when the message was read0
deletedBystringUID of the user who deleted the messagenull
deliveredAtnumberEpoch timestamp when the message was delivered1745554750
deletedAtnumberEpoch timestamp when the message was deleted0
replyCountnumberNumber of replies to this message0
senderobjectSender user objectSee below \u2193
receiverTypestringType of the receiver"user"
editedAtnumberEpoch timestamp when the message was edited0
parentMessageIdnumberID of the parent message (for threads)0
readByMeAtnumberEpoch timestamp when read by the current user0
categorystringMessage category"message"
deliveredToMeAtnumberEpoch timestamp when delivered to the current user0
updatedAtnumberEpoch timestamp when the message was last updated1745554729
unreadRepliesCountnumberCount of unread replies0
quotedMessageIdnumberID of the quoted messagenull

sender Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the sender"cometchat-uid-1"
namestringDisplay name of the sender"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

receiver Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the receiver"cometchat-uid-2"
namestringDisplay name of the receiver"George Alan"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"
metadataobjectCustom metadata{}
statusstringOnline status"offline"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745550000
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to process the reaction."
detailsstringAdditional technical details"An unexpected error occurred while processing the request."

Remove a Reaction

Call removeReaction() with the same message ID and emoji.
ParameterTypeDescription
messageIdintThe ID of the message to remove the reaction from.
reactionStringThe reaction emoji to remove (e.g., "\U0001f600", "\U0001f44d").
int messageId = 1;

CometChat.removeReaction(messageId, "\U0001f634", onSuccess: (message) {
  debugPrint("Success : ${message.getReactions().last}");
}, onError: (e) {
  debugPrint("Error: ${e.message}");
});
On Success — A BaseMessage object representing the message with the reaction removed:BaseMessage Object:
ParameterTypeDescriptionSample Value
idnumberUnique message ID401
metadataobjectCustom metadata attached to the message{}
receiverobjectReceiver user objectSee below \u2193
editedBystringUID of the user who edited the messagenull
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
sentAtnumberEpoch timestamp when the message was sent1745554729
receiverUidstringUID of the receiver"cometchat-uid-2"
typestringType of the message"text"
readAtnumberEpoch timestamp when the message was read0
deletedBystringUID of the user who deleted the messagenull
deliveredAtnumberEpoch timestamp when the message was delivered1745554750
deletedAtnumberEpoch timestamp when the message was deleted0
replyCountnumberNumber of replies to this message0
senderobjectSender user objectSee below \u2193
receiverTypestringType of the receiver"user"
editedAtnumberEpoch timestamp when the message was edited0
parentMessageIdnumberID of the parent message (for threads)0
readByMeAtnumberEpoch timestamp when read by the current user0
categorystringMessage category"message"
deliveredToMeAtnumberEpoch timestamp when delivered to the current user0
updatedAtnumberEpoch timestamp when the message was last updated1745554729
unreadRepliesCountnumberCount of unread replies0
quotedMessageIdnumberID of the quoted messagenull

sender Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the sender"cometchat-uid-1"
namestringDisplay name of the sender"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

receiver Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the receiver"cometchat-uid-2"
namestringDisplay name of the receiver"George Alan"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"
metadataobjectCustom metadata{}
statusstringOnline status"offline"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745550000
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to process the reaction."
detailsstringAdditional technical details"An unexpected error occurred while processing the request."
Both addReaction() and removeReaction() return a BaseMessage object with the updated reactions.

Read Reaction Data from a Message

Any BaseMessage exposes reaction data through its reactions property:

Get All Reactions

Use the reactions property to retrieve the list of reactions on a message. Returns a List<ReactionCount> containing the reactions, or an empty list if no one has reacted.
message.reactions

Check if the Logged-in User Has Reacted

Use the reactedByMe property on any ReactionCount object to check whether the logged-in user has reacted with that particular emoji. Returns true if they have, false otherwise.
for (ReactionCount reactionCount in message.reactions) {
    debugPrint("isReactedByMe ${reactionCount.reactedByMe}"); //Return true is logged-in user reacted on that message, otherwise false
}

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() (max 100 per request).
Builder PropertyTypeDescription
messageIdint?The message ID to fetch reactions for. Required.
reactionString?Filter to a specific emoji (e.g., "\U0001f60a"). When set, only reactions matching this emoji are returned.
limitintNumber of reactions to fetch per request. Default is 10.

Fetch Next

The fetchNext() method fetches the next set of reactions for the message.
int messageId = 1;

ReactionsRequest reactionsRequest = (ReactionsRequestBuilder()
  ..limit = 30
  ..messageId = messageId
).build();

reactionsRequest.fetchNext(
  onSuccess: (reactions) {
    for (Reaction reaction in reactions) {
      debugPrint("Success: $reaction");
    }
  },
  onError: (e) {
    debugPrint("Error: ${e.message}");
  },
);
The fetchNext() method returns a List<Reaction> representing individual user reactions on the message.
On Success — A list of Reaction objects for the message:Reaction Object (per item in list):
ParameterTypeDescriptionSample Value
idstringUnique reaction identifier"r1"
messageIdnumberID of the message this reaction belongs to1
reactionstringThe reaction emoji"\U0001f634"
uidstringUID of the user who reacted"cometchat-uid-1"
reactedAtnumberEpoch timestamp when the reaction was added1745554729
reactedByobjectUser who added the reactionSee below \u2193

reactedBy Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-1"
namestringDisplay name of the user"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to fetch the requested data."
detailsstringAdditional technical details"An unexpected error occurred while processing the request."

Fetch Previous

The fetchPrevious() method fetches the previous set of reactions for the message.
int messageId = 1;

ReactionsRequest reactionsRequest = (ReactionsRequestBuilder()
  ..limit = 30
  ..messageId = messageId
).build();

reactionsRequest.fetchPrevious(
  onSuccess: (reactions) {
    for (Reaction reaction in reactions) {
      debugPrint("Success: $reaction");
    }
  },
  onError: (e) {
    debugPrint("Error: ${e.message}");
  },
);
On Success — A list of Reaction objects for the message:Reaction Object (per item in list):
ParameterTypeDescriptionSample Value
idstringUnique reaction identifier"r1"
messageIdnumberID of the message this reaction belongs to1
reactionstringThe reaction emoji"\U0001f634"
uidstringUID of the user who reacted"cometchat-uid-1"
reactedAtnumberEpoch timestamp when the reaction was added1745554729
reactedByobjectUser who added the reactionSee below \u2193

reactedBy Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-1"
namestringDisplay name of the user"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to fetch the requested data."
detailsstringAdditional technical details"An unexpected error occurred while processing the request."

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.
class MyClass with MessageListener {

  String listenerID = "UNIQUE_LISTENER_ID";

  MyClass() {
    CometChat.addMessageListener(listenerID, this);
  }

  @override
  void onMessageReactionAdded(ReactionEvent reactionEvent) {
    debugPrint("Reaction added ${reactionEvent.reaction}");
  }

  @override
  void onMessageReactionRemoved(ReactionEvent reactionEvent) {
    debugPrint("Reaction removed ${reactionEvent.reaction}");
  }
}
Each reaction listener callback receives a ReactionEvent object containing:
ParameterTypeDescription
reactionReaction?The reaction that was added or removed.
receiverIdString?The UID or GUID of the receiver.
receiverTypeString?The type of the receiver ("user" or "group").
conversationIdString?The unique conversation identifier.
parentMessageIdint?The ID of the parent message (for threaded messages).

Remove the Listener

String listenerID = "UNIQUE_LISTENER_ID";

CometChat.removeMessageListener(listenerID);
Always remove listeners when they’re no longer needed (e.g., in the dispose() method). Failing to remove listeners can cause memory leaks and duplicate event handling.

Update a Message with Reaction Info

When you receive a real-time reaction event, you’ll want to update the corresponding message object so your UI reflects the change. CometChatHelper.updateMessageWithReactionInfo() does this — it takes the BaseMessage instance, the Reaction event data, and the action type, then returns the updated message.
ParameterTypeDescription
baseMessageBaseMessageThe message object to update.
messageReactionReactionThe reaction event received from the listener.
actionStringReactionAction.reactionAdded or ReactionAction.reactionRemoved
// Pass the message and Reaction from your listener (e.g. onMessageReactionAdded)
Future<void> refreshMessageWithReaction(
  BaseMessage message,
  Reaction messageReaction,
) async {
  // The received reaction event action type: reactionAdded or reactionRemoved
  var action = ReactionAction.reactionAdded;

  BaseMessage? modifiedBaseMessage =
      await CometChatHelper.updateMessageWithReactionInfo(
    message,
    messageReaction,
    action,
  );
  // Use modifiedBaseMessage?.reactions to refresh your UI
}
After calling this method, use modifiedBaseMessage?.reactions 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

Threaded Messages

Create and manage message threads

Mentions

Mention users and groups in messages