You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 13, 2026. It is now read-only.
Alexey Bukhtin edited this page Dec 11, 2019
·
6 revisions
// 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.
letactivity=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 inprint(result)}
// Read timeline and user's post appears in the feed:
timelineFeed?.get(pagination:.limit(10)){ result inletresponse=try! result.get()print(response.results)}
// Remove an activity by referencing it's foreignId
userFeed?.remove(foreignId:"picture:10"){ result inprint(result)}