commentId, which is an immutable string. When creating a new comment, you do not need to specify your own
commentId; you can leave it to Amity to generate one. We also provide optimistic updates on each comment. You will need to send a
referenceIdotherwise known as a
postId, in the latest version. You need to use
AmityCommentRepositorybefore starting any activity with comments, such as editing an operation and/or flagging a comment.
AmityCommentRepositoryto note, one makes a comment as well as getting a collection of comments. They all return a LiveObject with the complete comment model.
AmityCommentRepositoryclass. Before being able to call any comment method, you must initialize a repository instance using the
AmityClientinstance you created earlier during setup:
posttype comment is a comment that is intended for a regular post. A
contenttype comment on the other hand is intended for a content type post. A content type comment will automatically create a content post if the
referenceIddoes not exist yet.
AmityCommentRepositoryprovides one convenient method to create comment. You can provide
textwhile creating a comment.
parentIdis an optional parameter and useful for replying to a comment. The concept is similar to the
AmityMessageyou can reply to a message object with a
textdata will be supported in the creation method.
commentIdonce it has been successfully created. It first instantiates the
AmityCommentRepository, a class that contains all comment-related methods. Then it calls
createComment:to obtain the LiveObject and observe it in order to obtain the final comment model.
AmityNotificationTokenreturned by the
observeOnceWithBlock:is saved in
self.token, a strongly referenced property. This is needed in order to prevent the observe block to be released.The
createComment:is mandatory and will only support
AmityCommentRepositoryprovides method to get the query. The
getCommentsWithReferenceId(_:)are the methods to return the LiveCollection of all the matching comments available. Like other LiveObjects, the collection return will help automatically update and notify you on any comment modifications (e.g. new comment, deleted comment, modified comment, flagged comment).
You can order the comments in descending order (i.e latest comment first). In this case, you will have to call
previousPage()method to fetch more comments. Please look into the method documentation for more details.
lastparameters. By default, the number of items in each page is 20. To handle pagination to load more comments, refer to Pagination in Live Objects.
getLatestCommentmethod. This method returns the Live Object which you can observe.
AmityCommentEditorinstantiates by using the selected
isDeletedflag is set to
AmityCommentRepository. It provides a
deleteComment:method. You need to pass the
commentIdand a boolean parameter. Set the boolean parameter to
truefor hard delete and
falsefor soft delete.
AmityCommentFlaggerinstantiates by using the selected
client. They have three methods which are
AmityCommentobject includes information about the reactions for that post. Use
myReactionsproperty to get a list of your reactions to the post. Use
reactionsproperty to get a list of all reactions to the post and
reactionsCountprovides the total count of reactions on that post.