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 fetchMessages() to fetch historical messages in a space with reactions from storage using start and end timestamps.
To fetch the 100 most recent messages in a space, call fetchMessages() with neither the start nor the end parameter. You can iterate through the message history by adjusting the start and end timetokens to page through the full set of results if more than 100 messages need to be fetched.
Using Start and End Parameters
If only the start parameter is specified (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).