Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

Follows

Follow & Unfollow

// Follow a user
let timeline = client.feed(group: "timeline", id: "john")
_ = try await timeline.follow(FeedId(group: "user", id: "tom"))

// Follow a stock
_ = try await timeline.follow(FeedId(group: "stock", id: "apple"))

// Follow with more fields
_ = try await timeline.follow(
    FeedId(group: "stock", id: "apple"),
    custom: ["reason": "investment"]
)

Querying Follows

// Do I follow a list of feeds
// My feed is timeline:john
let followQuery = FollowsQuery(
    filter: .and([
        .equal(.sourceFeed, "timeline:john"),
        .in(.targetFeed, ["user:sara", "user:adam"])
    ])
)
let followList = client.followList(for: followQuery)
let page1 = try await followList.get()
let page2 = try await followList.queryMoreFollows()
let page1And2 = followList.state.follows

// Paginating through followers for a feed
// My feed is timeline:john
let followerQuery = FollowsQuery(
    filter: .equal(.targetFeed, "timeline:john")
)
let followerList = client.followList(for: followerQuery)
let followerPage1 = try await followerList.get()

Follows Queryable Built-In Fields

nametypedescriptionsupported operationsexample
source_feedstring or list of stringsThe feed ID that is following$in, $eq{ source_feed: { $eq: 'messaging:general' } }
target_feedstring or list of stringsThe feed ID being followed$in, $eq{ target_feed: { $in: [ 'sports:news', 'tech:updates' ] } }
statusstring or list of stringsThe follow status$in, $eq{ status: { $in: [ 'accepted', 'pending', 'rejected' ] } }
created_atstring, must be formatted as an RFC3339 timestampThe time the follow relationship was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Follow Requests

Some apps require the user’s approval for following them.

// Sara needs to configure the feed with visibility = followers for enabling follow requests
let saraFeed = saraClient.feed(
    for: .init(
        group: "user",
        id: "sara",
        data: .init(visibility: .followers)
    )
)
try await saraFeed.getOrCreate()

// Adam requesting to follow the feed
let adamTimeline = adamClient.feed(group: "timeline", id: "adam")
try await adamTimeline.getOrCreate()

let followRequest = try await adamTimeline.follow(saraFeed.feed) // user:sara
print(followRequest.status) // .pending

// Sara accepting
try await saraFeed.acceptFollow(
    adamTimeline.feed, // timeline:adam
    role: "feed_member" // optional
)
// or rejecting the request
try await saraFeed.rejectFollow(adamTimeline.feed) // timeline:adam

Push Preferences on Follow

When following a feed, you can set push_preference to control push notifications for future activities from that feed:

  • all - Receive push notifications for all activities from the followed feed
  • none (default) - Don’t receive push notifications for activities from the followed feed

Note: The push_preference parameter controls future notifications from the followed feed, while skip_push controls whether the follow action itself triggers a notification.

Examples: Push Preferences vs Skip Push

Understanding the difference between push_preference and skip_push:

// Scenario 1: Follow a user and receive notifications for their future activities
await timeline.follow("user:alice", {
  push_preference: "all", // You'll get push notifications for Alice's future posts
});

// Scenario 2: Follow a user but don't get notifications for their activities
await timeline.follow("user:bob", {
  push_preference: "none", // You won't get push notifications for Bob's future posts
});

// Scenario 3: Follow a user silently
await timeline.follow("user:charlie", {
  skip_push: true, // Charlie won't get a "you have a new follower" notification
  push_preference: "all", // But you'll still get notifications for Charlie's future posts
});

// Scenario 4: Silent follow with no future notifications
await timeline.follow("user:diana", {
  skip_push: true, // Diana won't know you followed her
  push_preference: "none", // And you won't get notifications for her posts
});
© Getstream.io, Inc. All Rights Reserved.