Fetch Comment Likes
The Fetch Comment Likes feature in the LM iOS SDK enables users to retrieve information about the number of likes received by a specific comment. This functionality allows developers to display the total number of likes on a comment, providing users with social validation and engagement metrics. By incorporating the Fetch Comment Likes feature, developers can enhance the user experience and encourage active participation within the comment section of their application.
Steps to fetch likes on a comment
- Create a GetCommentLikesRequest object using
GetCommentLikesRequest.builder()
class by passing all the required parameters. - Call
getCommentLikes()
function using the instance ofLMFeedClient
. - Process the response LMResponse<GetCommentLikesResponse> as per your requirement.
// object of GetCommentLikesRequest
let request = GetCommentLikesRequest.builder()
.postId(ENTER_POST_ID) // post id of comment whose likes are fetched
.commentId(ENTER_COMMENT_ID) // id of comment whose likes are fetched
.page(1) // page number for paginated data
.pageSize(20) // page size for paginated data
.build()
LMFeedClient.shared.getCommentLikes(request) { response in
// response (LMResponse<GetCommentLikesResponse>)
if (response.success) {
// your function to process the response data
processResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}
note
Same function can be used to fetch likes on a reply as well. Just pass the id of the reply as comment id.
Models
GetCommentLikesRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | String | Post ID of the comment whose likes are fetched. | |
commentId | String | ID of the comment whose likes are fetched. | |
page | Int | Page number of paginated like data. | |
pageSize | Int | Page size for paginated like data. |
GetCommentLikesResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
likes | Like[] | List of the likes on the comment. | |
totalCount | Int | Total count of likes on the commnet. | |
users | [String: User] | Dictionary of user unique id to user object. |