SDK settings
Constructor
init(transportConfig: ChatTransportConfig, networkConfig: ChatNetworkConfig = .init())
| Field | Type | Required | Description |
|---|---|---|---|
transportConfig | ChatTransportConfig | Yes | Connection settings (URL, API version). See Transport |
networkConfig | ChatNetworkConfig | No (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 SDKChatConfig 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:
| Property | Type | Default | Description |
|---|---|---|---|
userInputEnabled | Bool | true | Whether the input field is available to the user |
shouldUseRemoteConfig | Bool | true | When true, server values override the deprecated local settings below |
unreadMessageCountDelay | Int (sec) | 0 | REST polling interval for the unread counter. With 0, no polling |
Deprecated parameters (server-driven)
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.
| Property | Type | Default | Description |
|---|---|---|---|
searchEnabled | Bool | true | Search across message history |
voiceRecordingEnabled | Bool | false | Recording and sending voice messages |
scrollToLatest | Bool | true | Auto-scroll to new messages and when returning to the chat screen with loaded history |
linkPreviewEnabled | Bool | false | Link preview generation (OpenGraph) |
showAttachButton | Bool | true | Whether to show the attach files button |
surveyCompletionDelay | Int (ms) | 0 | Delay before sending survey results. Despite the name not having Ms, units are milliseconds |
historyLoadingCount | Int | 30 | Number of items loaded per history request |
keepSocketActive | Bool | false | Keep the WebSocket active after leaving the chat screen |
keepSocketActiveDuringOperatorSession | Bool | false | Keep the WebSocket active until the dialog is closed by the operator |
keepSocketActiveAn active WebSocket increases background battery and traffic consumption — only enable it if your application needs a real-time unread counter.
Examples
Minimal (recommended for a start)
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.
registerAtFirstStartWhen 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 state | keepSocketActive = false (default) | keepSocketActive = true | keepSocketActiveDuringOperatorSession = true |
|---|---|---|---|
| Chat open | WebSocket active | WebSocket active | WebSocket active |
| Chat closed, user authorized | WebSocket closed | WebSocket active | WebSocket active (until the dialog is closed by the operator) |
Chat closed, dialog ended by operator (closing — on the next closeChat()) | WebSocket closed | WebSocket active | WebSocket closed |
| Application in background | WebSocket closed | WebSocket closed | WebSocket closed |
After logout() / deauthorizeUser() | WebSocket closed | WebSocket closed | WebSocket closed |
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.
Related
- Errors reference — choosing between
keepSocketActiveandkeepSocketActiveDuringOperatorSession - SDK delegate —
didChangeUnreadMessages, network errors - Lifecycle integration — full diagram and threading