Skip to main content

Fetch Post Likes

The Fetch Post Likes feature in the iOS Feed SDK allows users to retrieve information about the number of likes received by a specific post. By utilizing this functionality, developers can display the total number of likes on a post and provide users with social validation and engagement metrics.

Steps to fetch likes on a post

  1. Create a GetPostLikesRequest object using GetPostLikesRequest.builder() class by passing all the required parameters.
  2. Call getPostLikes() function using the instance of LMFeedClient.
  3. Process the response LMResponse<GetPostLikesResponse> as per your requirement.
// object of GetPostLikesRequest
let request = GetPostLikesRequest.builder()
.postId(ENTER_POST_ID) // id of the post whose likes are fetched
.page(1) // page number for paginated data
.pageSize(20) // page size for paginated data
.build()
LMFeedClient.shared.getPostLikes(request) { response in
// response (LMResponse<GetPostLikesResponse>)
if (response.success) {
// your function to process the response data
processResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}

Models

GetPostLikesRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
postIdStringUnique id of the post whose likes are fetched
pageIntPage number of paginated like data
pageSizeIntPage size for paginated like data

GetPostLikesResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
likesLike[]List of the likes on the post.
totalCountIntTotal count of likes on the post.
users[String: User]Dictionary of user unique id to user object