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.
AI Integration Quick Reference
Field Value Key Classes BaseMessage, Reaction, ReactionCount, ReactionEvent, ReactionsRequest, ReactionsRequestBuilderKey Methods CometChat.addReaction(), CometChat.removeReaction(), ReactionsRequest.fetchNext(), ReactionsRequest.fetchPrevious(), CometChatHelper.updateMessageWithReactionInfo()Listener Events onMessageReactionAdded, onMessageReactionRemovedPrerequisites SDK initialized, user logged in
// Add a reaction to a message
CometChat . addReaction (messageId, " \U 0001f600" , onSuccess : (message) {
debugPrint ( "Reaction added: ${ message . getReactions (). last } " );
}, onError : (e) {});
// Remove a reaction from a message
CometChat . removeReaction (messageId, " \U 0001f600" , 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.
Add a Reaction
Call addReaction() with a message ID and an emoji string.
Parameter Type Description messageIdintThe ID of the message to react to. reactionStringThe reaction emoji (e.g., "\U0001f600", "\U0001f44d").
int messageId = 1 ;
CometChat . addReaction (messageId, " \U 0001f634" , 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: Parameter Type Description Sample Value idnumber Unique message ID 401metadataobject Custom metadata attached to the message {}receiverobject Receiver user object See below \u2193 editedBystring UID of the user who edited the message nullconversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"sentAtnumber Epoch timestamp when the message was sent 1745554729receiverUidstring UID of the receiver "cometchat-uid-2"typestring Type of the message "text"readAtnumber Epoch timestamp when the message was read 0deletedBystring UID of the user who deleted the message nulldeliveredAtnumber Epoch timestamp when the message was delivered 1745554750deletedAtnumber Epoch timestamp when the message was deleted 0replyCountnumber Number of replies to this message 0senderobject Sender user object See below \u2193 receiverTypestring Type of the receiver "user"editedAtnumber Epoch timestamp when the message was edited 0parentMessageIdnumber ID of the parent message (for threads) 0readByMeAtnumber Epoch timestamp when read by the current user 0categorystring Message category "message"deliveredToMeAtnumber Epoch timestamp when delivered to the current user 0updatedAtnumber Epoch timestamp when the message was last updated 1745554729unreadRepliesCountnumber Count of unread replies 0quotedMessageIdnumber ID of the quoted message null
sender Object:Parameter Type Description Sample Value uidstring Unique identifier of the sender "cometchat-uid-1"namestring Display name of the sender "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
receiver Object:Parameter Type Description Sample Value uidstring Unique identifier of the receiver "cometchat-uid-2"namestring Display name of the receiver "George Alan"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"metadataobject Custom metadata {}statusstring Online status "offline"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745550000
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to process the reaction."detailsstring Additional technical details "An unexpected error occurred while processing the request."
Remove a Reaction
Call removeReaction() with the same message ID and emoji.
Parameter Type Description 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, " \U 0001f634" , 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: Parameter Type Description Sample Value idnumber Unique message ID 401metadataobject Custom metadata attached to the message {}receiverobject Receiver user object See below \u2193 editedBystring UID of the user who edited the message nullconversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"sentAtnumber Epoch timestamp when the message was sent 1745554729receiverUidstring UID of the receiver "cometchat-uid-2"typestring Type of the message "text"readAtnumber Epoch timestamp when the message was read 0deletedBystring UID of the user who deleted the message nulldeliveredAtnumber Epoch timestamp when the message was delivered 1745554750deletedAtnumber Epoch timestamp when the message was deleted 0replyCountnumber Number of replies to this message 0senderobject Sender user object See below \u2193 receiverTypestring Type of the receiver "user"editedAtnumber Epoch timestamp when the message was edited 0parentMessageIdnumber ID of the parent message (for threads) 0readByMeAtnumber Epoch timestamp when read by the current user 0categorystring Message category "message"deliveredToMeAtnumber Epoch timestamp when delivered to the current user 0updatedAtnumber Epoch timestamp when the message was last updated 1745554729unreadRepliesCountnumber Count of unread replies 0quotedMessageIdnumber ID of the quoted message null
sender Object:Parameter Type Description Sample Value uidstring Unique identifier of the sender "cometchat-uid-1"namestring Display name of the sender "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
receiver Object:Parameter Type Description Sample Value uidstring Unique identifier of the receiver "cometchat-uid-2"namestring Display name of the receiver "George Alan"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"metadataobject Custom metadata {}statusstring Online status "offline"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745550000
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to process the reaction."detailsstring Additional 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.
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 Property Type Description 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): Parameter Type Description Sample Value idstring Unique reaction identifier "r1"messageIdnumber ID of the message this reaction belongs to 1reactionstring The reaction emoji "\U0001f634"uidstring UID of the user who reacted "cometchat-uid-1"reactedAtnumber Epoch timestamp when the reaction was added 1745554729reactedByobject User who added the reaction See below \u2193
reactedBy Object:Parameter Type Description Sample Value uidstring Unique identifier of the user "cometchat-uid-1"namestring Display name of the user "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to fetch the requested data."detailsstring Additional 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): Parameter Type Description Sample Value idstring Unique reaction identifier "r1"messageIdnumber ID of the message this reaction belongs to 1reactionstring The reaction emoji "\U0001f634"uidstring UID of the user who reacted "cometchat-uid-1"reactedAtnumber Epoch timestamp when the reaction was added 1745554729reactedByobject User who added the reaction See below \u2193
reactedBy Object:Parameter Type Description Sample Value uidstring Unique identifier of the user "cometchat-uid-1"namestring Display name of the user "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to fetch the requested data."detailsstring Additional 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:
Parameter Type Description 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.
Parameter Type Description 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