ChatEvent
public enum ChatEvent : Sendable
All events that can be emitted by the CXoneChat SDK.
Subscribe via events() and switch over the cases your app cares about.
Each case documents when it fires and what the consumer is typically expected to do.
-
The SDK’s connection lifecycle has advanced or the channel mode resolved.
Fires after
prepare(...)andconnect()complete (thestatetransitions through.preparing→.prepared→.connecting→.connected→.ready), and again on any later transition (e.g. to.offline). Themodereflects the channel’s configuration (.singlethread,.multithread,.liveChat) and is stable for the session.Consumers typically use this to gate UI: enable the “Open Chat” button at
.ready, show an offline state at.offline. -
A single thread changed — new messages arrived, the assigned agent changed, the thread name was updated, position in queue moved, etc.
Refresh the corresponding view (single-thread and live-chat channels). For multi-thread channels this also fires when an individual thread you are observing changes; if you only need the list, observe
threadsUpdated(_:)instead.Declaration
Swift
case threadUpdated(ChatThread) -
The full thread list changed — a thread was created, archived, or its last-message preview was updated. Multi-thread channels only.
Refresh your thread-list UI.
Declaration
Swift
case threadsUpdated([ChatThread]) -
The WebSocket connection dropped without an explicit
disconnect()orsignOut()call — e.g. the device lost the network, the server closed the connection, or a transport error fired.The SDK does not auto-reconnect. Consumers typically retry
connect()(possibly after a backoff) and surface a “Reconnecting…” state to the user.Declaration
Swift
case unexpectedDisconnect -
A custom plugin message was received from the agent side. The raw payload is delivered as
Dataso consumer-side handlers can decode app-specific schemas.Declaration
Swift
case customEventMessage(Data) -
An agent started or stopped typing in a specific thread.
Show or hide a typing indicator in the thread identified by
threadId. Theagentvalue carries the agent’s display info;isTyping == falseindicates the agent stopped (no separate “stopped” event).Declaration
Swift
case agentTyping(isTyping: Bool, agent: Agent, threadId: String) -
The currently active thread’s contact custom fields were accepted by the server.
Fires after a successful
set(_:for:)call. Consumers typically use this as confirmation to dismiss a “saving…” indicator.Declaration
Swift
case contactCustomFieldsSet -
The customer’s custom fields were accepted by the server.
Fires after a successful
set(_:)call. Consumers typically use this as confirmation to dismiss a “saving…” indicator.Declaration
Swift
case customerCustomFieldsSet -
The SDK encountered an error outside of an explicit
try/throwscall site — typically a server-side problem delivered asynchronously, a malformed event from the server, or a token-refresh issue that surfaced afterconnect()returned.Consumers should surface the error to the user (or log + retry) according to their product’s error-handling policy. Errors here do not terminate the events stream; subscribers continue receiving subsequent events.
Declaration
Swift
case error(Error) -
A backend-triggered proactive action arrived, such as an inactivity popup or satisfaction survey.
Switch on the associated value to present the action. Respond to an inactivity popup through
trigger(_:); present a satisfaction survey using its prompt and URL over the conversation itsthreadIdidentifies — in multithread channels, hold it until the customer views that thread rather than presenting it over another one. CXoneChatUI currently handles both inactivity popups and satisfaction surveys automatically. Consumers building a custom UI onCXoneChatSDKdirectly must present both themselves. Seecs-inactivity-popup.mdfor the inactivity-popup flow andcs-satisfaction-survey.mdfor the survey flow.Declaration
Swift
case proactiveActionReceived(ProactiveActionType)
View on GitHub