Comments
Here's an overview of how you can get started integrating comments into your applications
Each comment is identified by a unique 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 referenceId
otherwise known as a postId
, in the latest version. You need to use EkoCommentRepository
before starting any activity with comments, such as editing an operation and/or flagging a comment.
There are 2 methods in EkoCommentRepository
to note, one makes a comment as well as getting a collection of comments. They all return a LiveObject with the complete comment model.
Comment management methods are contained in a EkoCommentRepository
class. Before being able to call any comment method, you must initialise a repository instance using the EkoClient
instance you created earlier during setup:
Create Comment
EkoCommentRepository
provides one convenient method to create comment. You can provide referenceId
, parentId
and text
while creating a comment. parentId
is optional parameters and useful for replying a comment. The concept is similar to the EkoMessage
you can reply a message object with a parentId
. For now, only text
data will be supported in the creation method.
The code above creates a comment and prints out the commentId
once it has been successfully created. It first instantiates the EkoCommentRepository
, a class that contain all comment related methods. Then it calls createComment:
to obtain the LiveObject and observe it in order to obtain the final comment model.
The
EkoNotificationToken
returned by theobserveOnceWithBlock:
is saved inself.commentToken
, a strongly referenced property. This is needed in order to prevent the observe block to be released.The
parent
parameter increateComment:
is optional.The
referenceId
parameter increateComment:
is a mandatory and will be only supportEkoPost
identifier.
Comments Query
The EkoCommentRepository
provides method to get the query. The channelsForFilter(_:)
and commentsWithReferenceId(_:)
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.
You can also fetch the latest single comment using getLatestComment
method. This method returns the Live Object which you can observe.
Edit Comment
For any editing operation either update or delete a comment you can use EkoCommentEditor
. EkoCommentEditor
instantiate by using the selected commentId
and the client
. They have 2 methods which are editText:withCompletion:
and deleteWithCompletion:
Flag Comment
For flagging operation either update or delete a comment you can use EkoCommentFlagger
. EkoCommentFlagger
instantiate by using the selected commentId
and the client
. They have 3 methods which are flagWithCompletion:
, unflagWithCompletion:
and isFlagByMeWithCompletion:
Reactions
EkoComment
object includes information about the reactions for that post. Use myReactions
property to get list of your reactions to the post. Usereactions
property to get list of all reactions to the post and reactionsCount
provides the total count of reactions on that post.
To add or remove reaction, please refer to documentation for EkoReactionRepository
.
Last updated