Message Reactions allow users to send back an emoji reaction (e.g. thumbs up, smiley face, etc.) 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 like thumbs up, smiley face, etc.
Custom reactions to attach any state to a message like completed, reviewed, approved, etc.
Add a reaction to a message
Use addMessageAction() to add a reaction to a message in a space. You can use the method to add an emoji reaction to a message or to add any custom reaction as long as it is a string.
You need to provide your own emoji library; this is not included in the PubNub SDKs.
Remove a reaction from a message
Use removeMessageAction() to remove a reaction from a message. The reaction can only be removed by the user who added that reaction.
Get message reactions in a space
Use getMessageActions() to fetch reactions in a space from storage using start and end timestamps. This method can be used 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 (or fetchActions in Swift) flag to fetch past messages in a space along with reactions that were added to those messages.
To fetch the 25 most recent messages in a space, 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.
Using Start and End Parameters
If you specify only the start parameter (without end), you will receive messages that are older than and up to that start timetoken value.
If only the end parameter is specified (without start) you will receive messages that match that end timetoken value and newer.
Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value).