Skip to main content
Version: 5.9.0

SDK settings

Constructor

init(transportConfig: ChatTransportConfig, networkConfig: ChatNetworkConfig = .init())

FieldTypeRequiredDescription
transportConfigChatTransportConfigYesConnection settings (URL, API version). See Transport
networkConfigChatNetworkConfigNo (default .init())Network settings. Defaults: REST/WS connection 30 s, upload 120 s, no SSL pinning. See Network settings
let chatConfig = ChatConfig(transportConfig: chatTransportConfig)
ChatConfig is copied when passed to the SDK

ChatConfig is a struct, so ChatCenterUISDK(chatConfig:) stores a copy. Mutations to the local variable after SDK initialization have no effect — set all values before passing it to the constructor.

Active parameters

Parameters that do not depend on the server-side config:

PropertyTypeDefaultDescription
userInputEnabledBooltrueWhether the input field is available to the user
shouldUseRemoteConfigBooltrueWhen true, server values override the deprecated local settings below
unreadMessageCountDelayInt (sec)0REST polling interval for the unread counter. With 0, no polling

Deprecated parameters (server-driven)

Server-side config overrides these parameters

When shouldUseRemoteConfig = true (default), the server-side channelConfig overrides their local values — to make local values take effect, set shouldUseRemoteConfig = false.

The @available(deprecated) attribute is set in the doc comment, not in code — Xcode does not show strikethrough or Fix-It. Find usages by going through the list below.

PropertyTypeDefaultDescription
searchEnabledBooltrueSearch across message history
voiceRecordingEnabledBoolfalseRecording and sending voice messages
scrollToLatestBooltrueAuto-scroll to new messages and when returning to the chat screen with loaded history
linkPreviewEnabledBoolfalseLink preview generation (OpenGraph)
showAttachButtonBooltrueWhether to show the attach files button
surveyCompletionDelayInt (ms)0Delay before sending survey results. Despite the name not having Ms, units are milliseconds
historyLoadingCountInt30Number of items loaded per history request
keepSocketActiveBoolfalseKeep the WebSocket active after leaving the chat screen
keepSocketActiveDuringOperatorSessionBoolfalseKeep the WebSocket active until the dialog is closed by the operator
Battery impact of keepSocketActive

An active WebSocket increases background battery and traffic consumption — only enable it if your application needs a real-time unread counter.


Examples

let chatConfig = ChatConfig(transportConfig: chatTransportConfig)

With a persistent unread counter

var chatConfig = ChatConfig(transportConfig: chatTransportConfig)
chatConfig.shouldUseRemoteConfig = false
chatConfig.keepSocketActive = true
chatConfig.unreadMessageCountDelay = 30 // fallback polling, seconds

let sdk = ChatCenterUISDK(providerUid: ..., chatConfig: chatConfig)

WebSocket connection lifecycle

The WebSocket opens on the first getChat() (on the chat screen's viewDidAppear), not on authorize(). keepSocketActive controls closing, not opening. The full diagram is in Lifecycle integration.

Exception: registerAtFirstStart

When registerAtFirstStart = true (controlled server-side), the SDK opens the WebSocket in pre-registration mode right after authorize() if there is no saved deviceAddress in local storage, and closes it before the first getChat() — except when keepSocketActive = true.

Behavior depending on settings

Application statekeepSocketActive = false (default)keepSocketActive = truekeepSocketActiveDuringOperatorSession = true
Chat openWebSocket activeWebSocket activeWebSocket active
Chat closed, user authorizedWebSocket closedWebSocket activeWebSocket active (until the dialog is closed by the operator)
Chat closed, dialog ended by operator (closing — on the next closeChat())WebSocket closedWebSocket activeWebSocket closed
Application in backgroundWebSocket closedWebSocket closedWebSocket closed
After logout() / deauthorizeUser()WebSocket closedWebSocket closedWebSocket closed
Application in background

Going to the background (UIApplication.didEnterBackgroundNotification) currently always closes the WebSocket — keepSocketActive does not affect this transition. On returning to the foreground, call getUnreadMessagesCount(completion:) to refresh the unread counter.