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
- Create a GetFeedRequest object using
GetFeedRequest.builder()
class by passing all the required parameters. - Call
getFeed()
function using the instance ofLMFeedClient
. - 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
- Fetch the topics in your community by calling the
getTopics()
function using the instance ofLMFeedClient
. - Select the topics on which you want to filter your universal feed and send the IDs of these topics in
topicIds
ofGetFeedRequest.Builder
. - 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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
page | Int | Page number for paginated feed data. | |
pageSize | Int | Page size for paginated feed data. | |
topicIds | String[] | Array of Topic IDs selected by user | ✔ |
GetFeedResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
posts | Post[] | 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. |