Create Comment

Here's an overview of how you can start integrating comments into your applications

Amity Social SDK's comment creation is designed to handle comments in a fast and reliable way throughout your application. Each comment is given a unique commentId that cannot be changed, and the SDK includes an optimistic update feature. To work with comments, you'll need to use the CommentRepository.

With the SDK's optimistic creation feature for comments, you don't need to create a unique commentId yourself. Instead, the SDK generates one automatically for you. However, you'll need to provide a referenceId and referenceType. This feature allows the app to display the comment optimistically, assuming that it will be added successfully. This improves the user experience by reducing perceived latency.

A comment should not exceed 20,000 characters in length.

The AmityNotificationToken returned 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 parentId parameter in createComment: is optional.

The referenceId parameter in createComment: is mandatory and will only support AmityPost identifier.

Create Comment with Image

Amity Social SDK also allows you to create comments with images. When creating a comment with images, you can use the SDK's optimistic creation feature just like with text comments. The SDK will automatically generate a unique commentId for the image comment. However, in addition to the referenceId and referenceType, you'll also need to provide the image data in the form of fileId.


  1. Users can use a maximum of 10 images per comment.

  2. The supported file types with the image moderation feature is enabled are jpg/jpeg + png.

  3. The supported file types when the image moderation feature is not enabled are jpg/jpeg + webp

  4. The maximum file size per image is 1 GB.

Reply to a Comment

In addition to creating top-level comments, Amity Social SDK also allows you to reply to existing comments. To reply to a comment, you'll need to specify the parent comment's commentId as one of the parameters. This allows the SDK to associate the new comment as a reply to the parent comment.

Similar to creating a top-level comment, you can use the SDK's optimistic creation feature to create a reply comment. You don't need to provide a unique commentId for the reply comment, as the SDK generates one automatically. Instead, you'll need to provide the parentId, referenceId, referenceType, and the text content of the reply.

Reply Comments with Image

Last updated