Feed & Timeline
Let your users showcase their unique personality right in their timelines
Feed is a great way for users to get relevant updates, communicate and express themselves via algorithmically ranked content.
Each feed consists of a collection of posts. Users will be able to create posts on any groups that they are a member of and any user that they can find.
There are 3 types of feeds:
  1. 1.
    User Feed This is a collection of posts for a user's timeline.
  2. 2.
    Group Feed This is a collection of posts from members of the group or community.
  3. 3.
    Global Feed This is an aggregate of both User and Group feeds.
Feed management methods are all contained in AmityFeedRepository class.
Create AmityFeedRepository

Query User Feed

Querying for feed fetches your posts in your own feed or other user's feed. You can also sort the posts by lastCreated or firstCreated timestamp. AmityUserFeedSortOption enum provides both sort options which you can provide as argument while fetching feed.
AmityFeedRepository class exposes two convenient methods getMyFeedSortedBy(_:) and getUserFeed(_:) to query for your own feed and other user's feed respectively. getUserFeed(_:) method requires an additional parameter userId.
Get user feed
There is a quick easy method to get your own feed:
Get my fed

Query Group Feed

You can get any group's feed by calling the method below with the communityId. Fetching more posts for Group Feed is the same as User Feed.
Get community feed

Query Global Feed

There are two ways to retrieve your global feed. You can either use the getGlobalFeed method or the getCustomPostRankingGlobalFeed method.
1. Using getGlobalFeed If you query posts using this method, the post will be returned in chronological order. Below is the sample code.
Get global feed
2. Using getCustomPostRankingGlobalFeed Query custom post ranking is a smarter global feed that supports a score-sorting mechanism. Refer to Custom Post Ranking for more information about this feature. You can retrieve your global feed sorted by ranking score by calling the following method.
Get global feed with custom ranking
Fetching more posts in global feed is the same as User Feed.

Implementing feed pagination

Whether you're querying a user, group, or global feed, Live Collection will return a maximum of 20 posts in each page. To implement feed pagination:
The example of feed pagination in a view controller