// Setup a shared Stream Client.
Client.config = .init(apiKey: "<#ApiKey#>", appId: "<#AppId#>")
// Setup a Stream user, when your user was logged in.
Client.shared.setupUser(token: token) { _ in
// Do all your requests from here. Reload feeds and etc.
}
// Create a user feed.
// ⚠️ Make sure your feeds are instance variables to wait for the result: `var userFeed: FlatFeed?`
userFeed = Client.shared.flatFeed(feedSlug: "user")
// Create an Activity. You can make own Activity class or struct with custom properties.
let activity = Activity(actor: User.current!, verb: "add", object: "picture:10", foreignId: "picture:10")
userFeed?.add(activity) { result in
// A result of the adding of the activity.
print(result)
}
// Create a following relationship between "timeline" feed and "user" feed:
timelineFeed = Client.shared.flatFeed(feedSlug: "timeline")
timelineFeed?.follow(toTarget: userFeed!.feedId, activityCopyLimit: 1) { result in
print(result)
}
// Read timeline and user's post appears in the feed:
timelineFeed?.get(pagination: .limit(10)) { result in
let response = try! result.get()
print(response.results)
}
// Remove an activity by referencing it's foreignId
userFeed?.remove(foreignId: "picture:10") { result in
print(result)
}