Link Search Menu Expand Document

Using Core layer directly

If you want to design a completely custom user interface or if you develop an app that is not based on UIKit, you can ignore our UI layer and use only Core layer of the LivedDigitalChatSDK.

To do that, you instantiate the root SDK object (ChatCore) and explore controllers that it provides:

let appId = AppId(value: "XXX")
let authenticator = ExternalAuthenticator()
authenticator.delegate = ...
let chatCore = StockChatCore(appId: appId, authenticator: authenticator)

let channelsList = chatCore.channels

// Pass `channelsList.channels` to the UI layer to render current channels list state.
ui.renderChannels(channelsList.channels)

// `channelsList.delegate` is notified when channels are updated.
channelsList.delegate = ...

// `ChannelId` could be selected from `ChannelsList`,
// or you can match channels to your application domain objects,
// like rooms in a video-conference app or rounds in online game.
let channelId = ChannelId(value: "XXX")
let channel = channelsList.channel(for: channelId)

let messagesList = channel.messages
// Pass `messagesList.messages` to the UI layer to render current chat state.
ui.renderMessages(messagesList.messages)

// `MessagesList` observers are notified when chat feed is updated.
messagesList.subscribe(observer: ...)

// Send a message.
messagesList.send("Hello world!")