SDK initialization and configuration
We recommend initializing the SDK once at app startup (e.g., in AppDelegate).
The ChatCenterUISDK constructor is synchronous and does not perform network requests — it does not delay app startup. REST starts on authorize(user:), WebSocket starts on getChat().
Delayed or repeated calls to the constructor are allowed — for example, when switching between test and production environments. In the demo, server switching is shown in MainViewController.
- SDK initialization
- User authorization
- Opening the chat
Basic steps
Configure the server connection. The providerUid, rest, webSocket and dataStore values are issued by edna when the channel is created and are available in the admin workplace — see Mobile chat iOS connection → Channel installation setup. If you have no access to the admin workplace, request the values from edna technical support.
let chatTransportConfig = ChatTransportConfig(
rest: "https://your-host.edna.io",
webSocket: "wss://your-host.edna.io/socket",
dataStore: "https://your-host.edna.io/files"
)
or use the simplified constructor for edna cloud deployments:
let chatTransportConfig = ChatTransportConfig(cloudHost: "your-host.edna.io")
cloudHost formatPass a bare hostname (without a scheme) — the SDK will substitute https://, wss://…/socket and https://…/files itself. Passing "https://your-host.edna.io" will produce malformed URLs.
Pass the transport configuration to ChatConfig:
let chatConfig = ChatConfig(transportConfig: chatTransportConfig)
Initialize the SDK with the prepared chatConfig:
let chatCenterSDK = ChatCenterUISDK(providerUid: "YOUR_PROVIDER_UID",
chatConfig: chatConfig,
loggerConfig: ChatLoggerConfig(logLevel: .all))
Keep the instance alive for the entire duration of chat operation (usually equals the app lifetime). For access from anywhere, use a singleton or a DI container.
appMarker parameter
appMarker is an optional string application identifier passed during initialization:
let chatCenterSDK = ChatCenterUISDK(providerUid: "YOUR_PROVIDER_UID",
appMarker: "my-app-prod",
chatConfig: chatConfig)
The server uses appMarker to distinguish requests from different apps or environments of a single provider (for example, prod and test, or different brands of the same provider). The value is set by the integrator — typically a string of the form <app>-<env> (for example, mybank-ios-prod). If your setup has a single app and a single environment, the parameter can be omitted (nil by default). If you use routing by appMarker, agree on the value format with edna technical support.
For the full list of constructor parameters, see SDK initialization settings.
When to assign the delegate
We recommend setting the delegate property immediately after init — but no later than authorize(user:):
chatCenterSDK = ChatCenterUISDK(providerUid: ..., chatConfig: ...)
chatCenterSDK.delegate = self
Assigning the delegate before authorize(user:) guarantees that callbacks will not be missed during the first sync with the server — for example, unread counter updates and network state events. For details on delegate methods and thread safety, see SDK delegate.
Call sequence
Steps A–F run once at app startup; steps G–H run every time the chat is opened.
What's next
- Displaying the chat — user authorization and opening the chat
- App lifecycle integration — full integration diagram
- SDK initialization settings — all constructor parameters
- SDK settings — chat functionality parameters
- Design system — appearance customization
- Mobile chat iOS connection (admin workplace) — where to get
providerUidand server URLs