Quick Reference for AI Agents & Developers
- Add reaction:
CometChat.addReaction(messageId:reaction:onSuccess:onError:) - Remove reaction:
CometChat.removeReaction(messageId:reaction:onSuccess:onError:) - Fetch reactions:
ReactionsRequestBuilder().setMessageId(messageId:).build()→fetchNext(onSuccess:onError:) - Listen for reactions:
onMessageReactionAdded(_:),onMessageReactionRemoved(_:)in message listener - Related: Send Message · Messaging Overview
Add a Reaction
Users can add a reaction to a message by callingaddReaction with the message ID and the reaction emoji.
- Swift
Sample Payloads - Add Reaction
Sample Payloads - Add Reaction
- Request
- Success Response
- Error Response
Method:
CometChat.addReaction(messageId:reaction:)More Sample Payloads - Multiple Reactions
More Sample Payloads - Multiple Reactions
- Add Heart Reaction
- Add Laugh Reaction
Request:
Updated Reactions List:
You can react on Text, Media and Custom messages.
Remove a Reaction
Removing a reaction from a message can be done using theremoveReaction method.
- Swift
Sample Payloads - Remove Reaction
Sample Payloads - Remove Reaction
- Request
- Success Response
- Error Response
Method:
CometChat.removeReaction(messageId:reaction:)Fetch Reactions for a Message
To get all reactions for a specific message, create aReactionsRequest using ReactionsRequestBuilder.
Fetch Next Reactions
- Swift
Sample Payloads - Fetch Reactions
Sample Payloads - Fetch Reactions
- Request
- Success Response
- Error Response
Method:
ReactionsRequest.fetchNext()Fetch Reactions for Specific Emoji
- Swift
Fetch Previous Reactions
- Swift
Real-time Reaction Events
Keep the chat interactive with real-time updates for reactions.- Swift
Sample Payloads - Reaction Events
Sample Payloads - Reaction Events
- onMessageReactionAdded
- onMessageReactionRemoved
Method:
onMessageReactionAdded(reactionEvent: ReactionEvent)ReactionEvent Object:Get Reactions List
To retrieve the list of reactions on a particular message:- Swift
Check if Logged-in User Has Reacted
- Swift
Update Message With Reaction Info
When you receive a real-time reaction event, use this method to update the message with the latest reaction information. This keeps your local message state in sync with the server.Method Signature
- Swift
Parameters
ReactionAction Enum Values
Usage Example - Reaction Added
- Swift
Usage Example - Reaction Removed
- Swift
Complete Real-Time Handling Example
- Swift
Sample Payloads - Update Message With Reaction Info
Sample Payloads - Update Message With Reaction Info
- Return Value
The method returns a
BaseMessage with updated reactions array:Each ReactionCount contains:
Notes:
- This is a synchronous method - no callbacks needed
- Always use this method to keep local message state in sync
- The returned message has updated reactions array
- Works with both user and group messages
- Handle both
REACTION_ADDEDandREACTION_REMOVEDevents