Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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.
Version 6
Beta (v0.0.1)
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
.
To create a comment with images, you will need to upload an image using #upload-images function and proving fileId
s in attachments
parameter. The SDK will then handle the rest and create the comment with the image optimistically.
The functionality isn't currently supported by this SDK.
Version 6
Beta (v0.0.1)
The functionality isn't currently supported by this SDK.
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.
Supported ✅ (please wait while we prepare a real example!)
Version 6
Beta (v0.0.1)
The functionality isn't currently supported by this SDK.
Version 6
Beta (v0.0.1)
The functionality isn't currently supported by this SDK.
Amity Social SDK offers the AmityComment data type, which supports two types of content: TEXT
and IMAGE
. Users can view comments that include text, images, or a combination of both, providing a more versatile and engaging experience for your app's users.
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
The Amity SDK provides a functionality that allows you to work with social features in your application, including the ability to retrieve a comment. In this section, we'll explore how to use the Amity SDK to retrieve a single comment from your application. By using a specific function provided by the SDK, you can retrieve a comment based on its ID, which provides a convenient way to access specific comment data. The retrieved result is returned as a live object of a comment. For more information on live objects, please refer to Live Objects/Collections.
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
To retrieve multiple comments, you can use getCommentByIds
method provided by CommentRepository
. This method accepts a collection of commentId
as a parameter and returns a Live Collection ofAmityComment
.
The functionality isn't currently supported by this SDK.
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
The Amity Social SDK offers the getLatestComment
method, allowing you to fetch the most recent comment by a reference within your application. Integrating this feature enhances the user experience by keeping them informed about the latest interactions among users.
Using the getLatestComment
method is straightforward: simply implement it to retrieve the latest comment by a reference, streamlining the process of accessing up-to-date information. Furthermore, the method returns a Live Object that you can observe for real-time updates once Realtime Events are subscribed, ensuring your app stays current with the latest comments and fostering a more interactive environment.
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
Refer to Comment reference type for a more detailed explanation of the reference type parameter.
The ability to query comments and their replies is essential for creating a robust and user-friendly commenting experience. By using the getComments()
method and passing in the appropriate parameters, you can retrieve the comments and replies that are most relevant to your users.
Comment Replies
The query returns a LiveCollection of all matching comments available. To retrieve replies to a specific comment, you can pass the commentId
as the parentId
. If you want to retrieve parent-level comments, pass parentId = null
. If you omit the parentId
, you'll receive all comments on all levels.
Deletion Filter
You can also use the includeDeleted()
method to query for deleted comments and their replies. By passing true
or false
to this method, you can include or exclude deleted comments from the results.
Note that if you use the includeDeleted()
method, you don't need to check the isDeleted()
method in the AmityComment
object for deleted comments.
Refer to #create-comment for a more detailed explanation of the referenceType
parameter.
To query for image comments only, you can use the dataTypes
parameter and pass the value TEXT
, IMAGE
, or both. There are two options for the dataTypes
parameter: any
and exact
.
any
- When you use the any
option, the retrieved comments will include any comment that contains at least one of the specified data types. For example, if you pass [image, text]
, the retrieved comments may contain only image content, only text content, or both image and text content.
exact
- On the other hand, when you use the exact
option, the retrieved comments will include only comments that contain all of the specified data types. For example, if you pass [image, text]
, the retrieved comments must contain both image and text content. If you pass [image]
, the retrieved comments must contain only image content.
Using exact filer parameter:
Using any filter parameter:
The functionality isn't currently supported by this SDK.
Version 6
Beta(v0.0.1)
The functionality isn't currently supported by this SDK.
Refer to the following Limitations on the use of images in comments.
Here's an overview of how you can get started integrating comments into your applications
Comment refers to a user-generated response or reaction to a specific piece of content, such as a post or a content. Comments enable users to engage in conversations and express their thoughts, opinions, and emotions about the content they see. They provide a way for users to interact with each other and create a sense of community around the content. Commenting is an essential feature for social platforms as it encourages user engagement, helps create a more immersive experience for users, and can be used to generate insights into user behavior and preferences. In a social SDK product, the SDK provides the necessary tools and functionality for developers to integrate commenting into their apps or websites.
Furthermore, a comment supports real-time events and Live Object features, for more information please refer to Live Objects/Collections and Realtime Events.
Incorporating comment reference types within your app enhances user engagement and promotes interaction, as it allows users to comment on both regular posts and content-specific posts. By differentiating between these two comment types, your app can provide a more organized and contextual commenting experience, catering to the diverse needs of your users and the content they interact with. Comment's referenceType
can be:
post type comment: A post type comment is designed for regular posts, such as text updates, photos, or videos shared by users. These comments are associated with the regular post and are displayed beneath it, facilitating conversation and interaction.
Content type comment: A content type comment, on the other hand, is intended for content-specific posts, such as articles, or other specialized content.
The functionality of comments can be utilized through the Comment Repository, which offers methods for interacting with a data source that stores posts. This includes methods for querying comments, creating a new comment, updating an existing comment, or deleting a comment.
The functionality isn't currently supported by this SDK.
Amity Social SDK provides a comment editing functionality that fosters accountability and user awareness within your application. This feature enables users to edit their own comments exclusively. Users can only edit their own comments, which encourages responsible interactions and maintains accountability. Upon completing an edit operation, the SDK updates the editedAt
property to the current time, reflecting the changes made by the user. You can then leverage the updated editedAt
timestamp to create a user interface that informs users of edited comments, fostering transparency.
For any editing operation - either update or delete a comment, you can use APIs from AmityCommentRepository
.
Version 6
Beta (v0.0.1)
Amity Social SDK extends its comment editing functionality to include images, allowing users to update their comments with images. This feature enables users to modify not only the text but also the images associated with their comments, providing a richer and more engaging experience for your app's audience.
Upon successful completion of the file upload process, you can include the image data as a parameter when updating comments as demonstrated in the code sample below.
The functionality isn't currently supported by this SDK.
Version 6
Beta (v0.0.1)
The functionality isn't currently supported by this SDK.
The SDK provides functionality for soft and hard deleting comments. Soft delete marks the comment as deleted while still keeping it in the system with the isDeleted
flag set to true. On the other hand, hard delete completely removes the comment data, including its reactions and replies, from the system.
The need for soft and hard delete functions arises when users want to manage the comments on their app. Soft delete is helpful in situations where the comment has been flagged and needs to be hidden from users without actually deleting the comment. Hard delete, on the other hand, is useful in cases where the comment content is inappropriate and must be permanently deleted from the app.
To hard delete a comment, you can use the AmityCommentRepository, which provides a deleteComment method. When using this method, you need to pass the commentId
and a boolean hardDelete
parameter. Set the boolean parameter to true for hard delete and false for soft delete. If you do not specify the boolean parameter, it will be set to false by default, equivalent to a soft delete. It's important to note that hard deleting children comments will not delete the parent comment.
It's worth mentioning that hard deleting posts and comments is only supported via SDK, with UIKit and Console support potentially being added in the future. By implementing the soft and hard delete features provided by Social SDK, you can give your app's users more control over the comments they interact with while maintaining a safe and appropriate community.
If you will not specify the boolean parameter, it will be set to false
by default which is just equivalent to a soft delete.
The deleteComment
method returns a promise acknowledging the server's successful response. Use await
to receive the result. It will return true
if the deletion is successful. Otherwise, it will return false
.
Version 6
Beta (v0.0.1)
Only the owner of the comment or an admin can update and/or delete a comment.
The myReactions
property allows users to retrieve a list of all reactions they have made on a particular comment. This feature makes it easy for users to keep track of their own reactions and to see how their engagement with the post has evolved over time.
The reactions
property, on the other hand, provides a list of all reactions made on the post. This includes reactions made by other users, providing a broader perspective on the post's overall engagement and sentiment.
Finally, the reactionsCount
property provides a simple way to get the total count of reactions on a comment. By using this property, users can quickly see how popular a post is and how engaged the community is with the content.
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
Supported ✅ (Please wait while we prepare a real example!)
Mentions allow users to tag other users in comments. It's a powerful tool for fostering engagement and collaboration within your social application. With mentions, users can easily notify specific individuals or groups to new content or important updates. In the SDK, mentions can be implemented in a range of ways, depending on your application's needs and user experience. For more information about mentions, please refer to .
You can easily mention users when creating a comment by including their user IDs in the mention user parameter as well as defining metadata for mention rendering. For further explanation, please refer to .
Version 6
Beta (v0.0.1)
We provide developers with an efficient method for updating comments with mentions of specific users, you can easily add mentions to their post updates and but it will not notify the relevant users.
To remove mentions you can provide an empty JSON object for the metadata parameter, and an empty list for the mention users parameter. By doing so, You can easily remove mentions from the post content, while ensuring that the overall structure of the post remains intact.:
To update a comment/reply with mentions, this is the method in AmityCommentEditor
:
Version 6
Beta (v0.0.1)
The Social SDK product also includes a flag method that allows users to flag comments in their app. Once a comment is flagged, an indicator will appear in the Admin console, where an administrator can review and validate the flag. If the content is found to be in violation of your app's policies, it can be deleted from the app. On the other hand, if the content is not found to be in violation, the flag can be revoked.
The flag method provides an essential tool for managing user-generated content in your app, ensuring that inappropriate comments can be quickly identified and removed. By integrating this method into your app's user interface, you can empower your users to take an active role in promoting a safe and respectful community.
Beta (v0.0.1)
Another useful feature is the unflag method, which enables users to revoke a previously flagged comment. If a user flags a comment by mistake or if the comment is found not to violate your app's policies after review, the unflag method can be used to remove the flag from the comment. It ensures that users have control over the content they flag and the ability to reverse their flag if necessary.
Beta (v0.0.1)
The isFlaggedByMe
method allows users to check whether they have previously flagged a particular comment. This method provides a convenient way for users to keep track of the content they have flagged and to ensure that they are staying up-to-date with their moderation activities.
By using the isFlaggedByMe method, your app's users can quickly determine whether they have already flagged a particular comment and avoid duplicating their efforts.
Beta (v0.0.1)
Prior to editing images in comments, it is crucial to upload the images that will be included in the comment data to ensure that the necessary information is accessible and can be linked to the comment. This requires uploading the file first, to obtain the file data that will be used in creating the file post. To upload a file, please refer to .
Refer to the following on the use of images in comments.
For more details on Reactions, refer to our documentation.
To render mentions in a supported feature, please refer to , specifically the section on handling mentions. This documentation provides detailed information on how to represent mentions in your application, including information on metadata structure, custom mention objects, and rendering support.
Name
Data Type
Description
commentId
String
ID of the comment
userId
String
ID of the user who posted the comment
parentID
String
ID of a parent comment
refrenceId
String
ID of a reference
referenceType
String
Type of a reference
dataType
String
Type of the comment
data
Object
Body of the comment
metadata
Object
Additional properties to support custom fields
childrenNumber
Number
Number of children comments
flagCount
Integer
Number of users who has read the comment
reactions
Object
Mapping of reaction with reactionCounter
reactionsCount
Integer
Number of all reactions for the comment
myReactions
Array<String>
List of my reactions to the comment
isDeleted
Boolean
Flag that determines if comment is deleted
editedAt
DateTime
Date/time when comment was edited
createdAt
DateTime
Date/time when comment was created
updatedAt
DateTime
Date/time when comment was updated or deleted
childrenComments
String
Children comments
hashflag
Object
Flag for checking internally if this comment is reported or not
mentionees
Array<String>
User IDs of the mentioned users