Reactions
Let users react to messages, posts, and comments, which are visible to others.
Reactions are the interactions that you can perform on messages, posts, or comments. The interactions can be anything such as like, dislike, love, etc. It's up to you to determine the type of reactions.
AmityReactionRepository
class provides a convenient method to add, remove, and query reactions for any content. Currently, reactions are supported for Posts, Messages and Comments.
Reaction Description
Name | Data Type | Description | Attributes |
|
| ID of a document | |
|
| Type of document | |
|
| Name of reaction | ' |
|
| ID of the reaction | |
|
| ID of the reactor | |
|
| Display name of the reactor | |
|
| The date/time when a reaction is created |
Query Reactions
You can fetch detailed information about reactions and the user who reacted to the post. AmityPostRepository
and AmityCommentRepository
classes provide two methods which get detailed information about reactions to the post and comment respectively. Each information is provided through AmityReaction
object.
You can fetch information about a particular reaction and all the reactions through the getReactions
method. The method returns collections of AmityReaction
.
Below is a sample code for getting reactions from a post:
Below is a sample code for getting reactions from a comment:
Add/Remove Reaction
You can add any reactions to a given post. You can also remove any reactions added to the post. AmityPost
and AmityComment
objects provide addReaction
and removeReaction
methods for adding and removing reactions respectively. Both methods accept the reactionName
the the required parameter.
Add Reaction
Below are sample codes for adding a reaction to a post and comment:
Post
Comment
Remove Reaction
Below are sample codes for removing a reaction from a post and comment :
Post
Comment
The reactionName
parameter is the reaction name. This 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.
Last updated