Skip to main content

MaestroKit: ChatPanel Component Documentation

Usage

import SwiftUI
import MaestroKit

struct ContentView: View {
@EnvironmentObject var maestroSDK: Maestro
let channelId: String
let siteId: String
let userJwt: String

var body: some View {
maestroSDK.chatPanel(
channelId: channelId,
siteId: siteId,
userJwt: userJwt
)
}
}

struct ContentView_Previews: PreviewProvider {
@EnvironmentObject static var maestroSDK: Maestro
static var previews: some View {
ContentView(
channelId: "YOUR_CHANNEL_ID",
siteId: "YOUR_SITE_ID",
userJwt: "YOUR_USER_JWT"
)
.environmentObject(maestroSDK)
}
}

Parameters

The Chat Panel View view accepts the following parameters:

  • channelId (required): The unique ID of the Maestro channel for which you want to display the live stream.
  • siteId (required): The unique ID of Maestro's site.
  • userJwt (required): User Token

Behavior

The Chat Panel View is designed to handle all chat interactions, including sending, receiving, and displaying messages. When the component is rendered, it initiates a connection to Maestro's chat service and begins listening for incoming messages.

Users can type messages into the input field and hit send to publish their messages to the channel. If a user has an associated profile picture, it will be displayed next to their messages. If not, a default icon will be used.

If there are no messages in the chat, a Be the first to chat! text will be shown.

Example chat panel

Chat panel

Example chat panel with no messages

Chat panel with no messages