Message Reaction
Interactions are more fun when you can express yourself! Let users react using emojis, stickers, or thumbs up to messages.
To maximize engagement on the content of your application, you can use reactions on messages, posts, or comments. The reaction is similar to Facebook's Like. While a user can add many reactions to a model, it can add each reaction one time only.

Reaction Description

Name
Data Type
Description
Attributes
referenceId
String
ID of a document
referenceType
String
Type of document
reactors
Array of Objects
List of mapping between reaction and reactor ID.
reactionName : ( 'like', 'love' , 'wow')
userID: ID of a creator
reactionId: ID of a reaction
createdAt: The date/time when a reaction is created

Reading the reactions

Each model which can be reacted upon will carry a set of properties useful to display its reactions. You will find:
  1. 1.
    reactions: an object containing the name of the reactions as key, and their count as value (ex: { like: 1, love: 1 })
  2. 2.
    reactionCount: the sum of all the counts for all the reactions
  3. 3.
    myReactions: an array containing the current's users reactions
const liveObject = MessageRepository.getMessage('messageId');
liveObject.on('dataUpdated', message => {
console.log(message.reactions); // { like: 1, love: 4, care: 3 }
console.log(message.reactionCount); // 8
console.log(message.myReactions); // ['love', 'care']
});

Reacting on a message

Before you can add or remove reactions, the message must be fetched from the server first using either of these methods:

Add Reaction

To add a reaction, call the addReaction and pass along the identifier for your reaction.
try {
const isAdded = await MessageRepository.addReaction({
messageId: 'messageId',
reactionName: 'love',
});
if (isAdded) {
console.log('reaction is added');
}
} catch (error) {
console.error('can not add reaction', error);
}

Remove Reaction

Just as you did for adding a reaction, you can call removeReaction to remove a reaction.
try {
const isRemoved = await MessageRepository.removeReaction({
messageId: 'messageId',
reactionName: 'love',
});
if (isRemoved) {
console.log('reaction is removed');
}
} catch (error) {
console.error('can not remove reaction', error);
}
Reactions can be "like", "love", "wow" and other reaction names which has a maximum length of 100 characters. It is case sensitive. This means that "like" and "Like" are two different reactions.
Export as PDF
Copy link
Outline
Reaction Description
Reading the reactions
Reacting on a message
Add Reaction
Remove Reaction