Skip to main content

Universal Feed

The SDK provides a powerful Universal Feed feature for your iOS app. Easily integrate a versatile feed that allows all the users in the community to view a common feed

Steps to fetch Universal feed

  1. Create a GetFeedRequest object using GetFeedRequest.builder() class by passing all the required parameters.
  2. Call getFeed() function using the instance of LMFeedClient.
  3. Process the response LMResponse<GetFeedResponse> as per your requirement.
// object of GetFeedRequest
let requestFeed = GetFeedRequest.builder()
.page(1) // page number for paginated feed data
.pageSize(10) // page size for paginated feed data
.build()
LMFeedClient.shared.getFeed(requestFeed) { [weak self] result in
// get response (LMResponse<GetFeedResponse>)
if (response.success) {
// your function to process the response data
processGetFeedResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}

Steps to fetch Universal feed with selected topics

  1. Fetch the topics in your community by calling the getTopics() function using the instance of LMFeedClient.
  2. Select the topics on which you want to filter your universal feed and send the IDs of these topics in topicIds of GetFeedRequest.Builder.
  3. You will get posts from universal feed that has atleast one of these topics.
// object of GetFeedRequest
let request = GetFeedRequest.builder()
.page(1) // page number for paginated feed data
.pageSize(10) // page size for paginated feed data
.topics(["6517c7de9110701a759024ef"]) // fetches posts with given topics from feed
.build()
LMFeedClient.shared.getFeed(request) { [weak self] result in
// get response (LMResponse<GetFeedResponse>)
if (response.success) {
// your function to process the response data
processResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}

Models

GetFeedRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
pageIntPage number for paginated feed data.
pageSizeIntPage size for paginated feed data.
topicIdsString[]Array of Topic IDs selected by user

GetFeedResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
postsPost[]List of posts inside feed.
users[String: User]Dictionary of user unique id to user object.
topics[String: Topic]Map of topic id to topic object.