Message Reactions allow users to send back an emoji reaction (for example, thumbs up or smiley face) or a custom reaction on a message that they received. These reactions are typically visible to all users in the chat room and displayed with the original message.
There are two main types of message reactions:
Emoji reactions to a message such as thumbs up or smiley face
Custom reactions to attach any state to a message, such as completed, reviewed, or approved
Add a reaction to a message
Use addMessageAction() to add a reaction to a message in a channel. You can use the method to add an emoji reaction to a message or to add any custom reaction as long as it's a string.
You need to provide your own emoji library; this isn't included in the PubNub SDKs.
Remove a reaction from a message
Use removeMessageAction() to remove a reaction from a message. A reaction can only be removed by the user who added that reaction.
Get message reactions
Use getMessageActions() to fetch reactions in a channel from storage using start and end timestamps. Use this method to fetch new reactions that were added after a certain timestamp when the user returns to the application.
Get messages with reactions
Use the includeMessageActions flag (or fetchActions in Swift) with the fetchMessages() method to fetch past messages in a channel along with reactions that were added to those messages.
To fetch the 25 most recent messages in a channel, fetch messages with neither the start nor the end parameter. If there are more than 25 messages to be fetched, you can iterate through the message history by adjusting the start and end timetokens to page through the full set of results.
Start and End parameters
Messages are always returned in chronological order — from oldest to newest — within the timetoken range you request.
If you specify only the start parameter (without end), you will receive messages older than the start timetoken value.
If you specify only the end parameter (without start), you will receive messages from the last (most recent) message going back to that timetoken value.
Specify values for both start and end to retrieve messages between those timetokens (inclusive of the end value).