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
- Create a GetPostLikesRequest object using
GetPostLikesRequest.builder()
class by passing all the required parameters. - Call
getPostLikes()
function using the instance ofLMFeedClient
. - 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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | String | Unique id of the post whose likes are fetched | |
page | Int | Page number of paginated like data | |
pageSize | Int | Page size for paginated like data |
GetPostLikesResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
likes | Like[] | List of the likes on the post. | |
totalCount | Int | Total count of likes on the post. | |
users | [String: User] | Dictionary of user unique id to user object |