Appearance
Swift SDK - Feeds API
About 814 wordsAbout 3 min
Comprehensive code examples for the Stream feeds swift SDK.
Quick Navigation
- Common (43 methods)
- Feeds (69 methods)
- Moderation (12 methods)
- Push & Notifications (15 examples)
- State Layer (12 examples)
- Types Reference - interfaces for API requests/responses
Overview
This documentation covers 124 API methods across 3 categories, plus 27 examples for Push & Notifications and State Layer.
Installation
// Add to Package.swift dependencies:
.package(url: "https://github.com/GetStream/stream-feeds-swift.git", from: "1.0.0")Basic Setup
import StreamCore
import StreamFeeds
let client = FeedsClient(
apiKey: APIKey("<your_api_key>"),
user: User(id: "john"),
token: "<user_token>"
)
try await client.connect()Categories
Common
getApp()- Retrieve the current application settings to understand and verify the configuration of your app. Use this method when you need to access or review the app's settings for troubleshooting or validation purposes.listBlockLists()- Obtain a list of all block lists to manage or review the existing lists effectively. Use this method when you need a comprehensive overview of all block lists in your system.createBlockList()- Establish a new block list to prevent certain elements from interacting with your application. This method is essential when introducing new restrictions or security measures.updateBlockList()- Modify an existing block list to add, remove, or change its entries. This is useful when updating the list to reflect new restrictions or allow previously blocked interactions.deleteBlockList()- Remove a block list to eliminate its restrictions from your application. Use this method when a block list is no longer needed, or when consolidating lists for efficiency.- ... and 38 more methods
Feeds
addActivity()- Add a single activity to a feed, allowing users to share updates or events. Use this when you want to introduce new content to a feed.upsertActivities()- Add or update multiple activities in a batch, optimizing feed management by ensuring activities are current and efficiently handled. Use this for bulk operations where activities might need to be created or modified.deleteActivities()- Remove multiple activities from a feed to keep it relevant and tidy. Use this when you need to clear outdated or unwanted content from a feed.trackActivityMetrics()- Monitors and records user interactions with activities, providing insights into user engagement and behavior. Use this to analyze activity trends and optimize content strategy.queryActivities()- Retrieve a list of activities based on specific criteria, enabling users to access relevant content quickly. Use this to filter and display activities that match certain conditions.- ... and 64 more methods
Moderation
appeal()- Submit a request to review and potentially overturn a moderation decision; use this when you believe a moderation action was taken in error.getAppeal()- Retrieve details about a specific appeal, allowing you to track the status and outcome of your request for review.queryAppeals()- Search and filter through multiple appeals to manage and assess ongoing or past moderation challenges effectively.ban()- Restrict a user from accessing services or content, useful when enforcing community guidelines and maintaining a safe environment.upsertConfig()- Create or update rules for content moderation, enabling customization and refinement of moderation strategies to suit specific needs.- ... and 7 more methods
Push & Notifications
- Push Configuration - APN - Configure push notifications using Apple Push Notification service (APN). Create a
PushNotificationsConfigwith APN provider info and pass it to theFeedsConfigwhen initializing the client. - Push Configuration - Firebase - Configure push notifications using Firebase Cloud Messaging (FCM). Create a
PushNotificationsConfigwith Firebase provider info and pass it to theFeedsConfig. - Push Configuration - Multi Bundle - Configure push notifications for multiple app bundles. This is useful when you have separate bundle identifiers for development and production, or for app extensions.
- AppDelegate Setup - Set up your
AppDelegateto handle push notification registration and forward the device token to the Stream SDK. - Register Device - Register a device for push notifications. Call
createDevice(id:)with the push token received from APNs to enable the device to receive push notifications. - ... and 10 more examples
State Layer
- FeedState - Getting Started - Access reactive, observable state for a feed using the
.stateproperty.FeedStateis anObservableObjectthat publishes changes to activities, followers, members, and notification status. Use it to drive SwiftUI views that automatically update when feed data changes. - FeedState - Observing Activities - Observe the list of activities in a feed. The
activitiesproperty onFeedStateis a published array that updates automatically when activities are added, removed, or modified. - FeedState - Observing Followers - Observe the followers of a feed. The
followersproperty onFeedStateprovides a reactive list of users following this feed. - FeedState - Observing Members - Observe the members of a feed. The
membersproperty onFeedStateprovides a reactive list of feed members, useful for group or collaborative feeds. - FeedState - Pagination - Load more activities using pagination. Call
queryMoreActivities(limit:)to fetch the next page of results. The state'sactivitiesarray is automatically appended with new data. - ... and 7 more examples
Generated from Stream OpenAPI specification