Public Chat Plugin Guide
Install and register the Public Chat plugin to enable channel-based chat inside the StreamLayer Element.
Public Chat Plugin Guide
The Public Chat plugin adds channel-based chat to the StreamLayer Element. It is an optional module backed by GetStream's stream-chat-swift SDK. To keep the core StreamLayer SDK binary small, stream-chat-swift is not shipped inside StreamLayerSDK — install and register this plugin only when your integration needs chat.
When the plugin is not registered the SDK hides the chat menu item and silently ignores chat overlay routes. There is no runtime crash and no surface in the StreamLayer Element changes.
Installation
– Install the latest version of the StreamLayer Plugins package.
– Add StreamLayerSDKPluginsPublicChat to your project's Frameworks, Libraries and Embedded Content section.
The plugin transitively links StreamChat and StreamChatUI from stream-chat-swift — no additional Swift Package or Pod is required.
StreamLayer Studio Configuration
Chat is enabled per organization in StreamLayer Studio. The SDK receives the GetStream API key, app ID, and channel list from the server during the standard configuration handshake — the plugin reads them automatically once registered.
Your StreamLayer JWT also pipes the GetStream user token; no separate token exchange is required from the host app.
If chat is disabled for the organization, registering the plugin is a no-op — the chat menu item still won't appear.
Permissions
Some chat features require iOS privacy permissions and rely on the Permissions Plugin being registered:
| Chat feature | Permissions Plugin required | Info.plist key |
|---|---|---|
| Photo attachment picker | Yes | NSPhotoLibraryUsageDescription |
| Live camera input | Yes | NSCameraUsageDescription |
| Text-only chat | No | — |
Register the Permissions plugin alongside the Public Chat plugin if your users will attach photos or open the camera from chat.
Registration
Register the plugin before initializing the SDK. The chat menu item visibility is decided at the time the server-side configuration arrives, which happens during StreamLayer.initSDK.
import StreamLayerSDK
import StreamLayerSDKPluginsPublicChat
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
configureSLPublicChatPlugin()
StreamLayer.initSDK(with: "YOUR_SDK_API_KEY", isDebug: false)
return true
}
private func configureSLPublicChatPlugin() {
let plugin: SLRPublicChatServiceProtocol = SLRPublicChatPlugin()
StreamLayer.registerPublicChatPlugin(plugin)
}
}SLRPublicChatPlugin is retained by the SDK after registration; you do not need to hold a reference yourself.
Theming
The chat UI is styled by SLRPublicChatAppearance. Customize the shared default instance once at app launch — the values are applied the first time chat opens.
import StreamLayerSDKPluginsPublicChat
SLRPublicChatAppearance.default.colorPalette.background = .systemBackground
SLRPublicChatAppearance.default.fonts.body = .systemFont(ofSize: 15, weight: .regular)The appearance hierarchy mirrors GetStream's StreamChatUI defaults but is shipped with the plugin, so importing StreamLayerSDKPluginsPublicChat is enough — you do not need to depend on stream-chat-swift directly.
Lifecycle
The plugin connects to GetStream lazily — the first time the user opens the chat overlay — and disconnects when the chat overlay is dismissed. The SDK takes care of both transitions; the host app does not call connect() or logout() directly.
If the user logs out of the StreamLayer SDK (StreamLayer.logout()), the plugin also drops its GetStream session.
Skipping the Plugin
If your integration does not need chat:
– Don't add StreamLayerSDKPluginsPublicChat to your target.
– Don't call StreamLayer.registerPublicChatPlugin(_:).
The chat menu item will not appear, and the SDK will skip any chat overlay route the server sends. Other interactive units (polls, predictions, ads, Watch Party) continue to work as configured.
See the Integration Guide for the surrounding SDK setup, and the Permissions Plugin Guide if your chat configuration needs photo or camera access.
Updated 4 days ago
