Skip to main content

Delete Comment

In the LikeMinds Android Feed SDK, users have the capability to delete their own comments. This functionality allows members to easily remove their comments from the post, providing them with control over their contributions and ensuring a clean and organized conversation environment.

note

Community Managers can also delete the comments of other members, but a reason is required.

Steps to delete a comment

  1. Create a DeleteCommentRequest object using DeleteCommentRequest.Builder class by passing all the required parameters.
  2. Call deleteComment() function using the instance of LMFeedClient.
  3. Process the response (LMResponse<Nothing>) as per your requirement.
CoroutineScope(Dispatchers.IO).launch {
// object of DeleteCommentRequest
val deleteCommentRequest = DeleteCommentRequest.Builder()
.postId("ENTER POST ID") // post id of the comment to be deleted
.commentId("ENTER COMMENT ID") // id of the comment to be deleted
.reason("ENTER REASON FOR COMMENT DELETION") // reason required when CM deletes others comment
.build()
// get response (LMResponse<Nothing>)
val response = LMFeedClient.getInstance().deleteComment(deleteCommentRequest)
if (response.success) {
// your function to process comment deleted action
processCommentDeleted()
} else {
// your function to process error message
processError(response.errorMessage)
}
}
note

Same function can be used to delete a reply as well. Just pass the id of the reply as comment id.

Models

DeleteCommentRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
postIdStringPost id of the comment to be deleted
commentIdStringUnique id of the comment to be deleted.
reasonStringReason for comment deletion.
note

reason is only required when Community Manager deletes other members comment.