Event Families
Events come in families: message, user, group, conversation, call, thread and UI.- SwiftUI
- UIKit
The bus is
CometChatEvents. Each family has a modifier that listens to every event in it,
and most events also have a modifier named after them.Events with no per-event modifier —
replyToMessage, messageEditedByOther,
messageDeletedByOther, messagesDeliveredToAll, messagesReadByAll, messageModerated,
interactionGoalCompleted, conversationUpdated, showPanel, hidePanel,
agentChatThreadResolved, cardActionClicked and the thread family’s
subscriptionChanged — arrive through the family modifier.Listening to Events
- SwiftUI
- UIKit
Every event has a modifier named after it. It listens while the view is on screen and stops
when the view goes. The closure receives the event’s fields.Each family also has one modifier for every event in it:Outside a view — in a store or a service — iterate the family’s stream. Leaving the loop, or
cancelling its task, stops listening.
Emitting Events
Some actions happen on screens you build — a profile screen with a block button, a group-details screen that adds members. The Kit cannot see them, so emit the event yourself, or the Kit’s lists go stale.- SwiftUI
- UIKit
Sending Through the Kit
Send through the Kit rather than the SDK, and the message is announced as it is sent, as it succeeds and if it fails — so the message list and Conversations update without any wiring.- SwiftUI
- UIKit
Send with
CometChatSession:The sender, the local id (
muid) and the sent time are filled in when missing. A custom
message is sent with its push notification on. On failure the message’s metadata holds the
error under error, errorCode and errorDetails, and the function throws.Thread Subscription
Following a thread is on by default.CometChatThreadSubscription holds the rules the Kit
uses; call it from your own control to stay in step with the Kit’s.
- SwiftUI
- UIKit
toggle updates every surface at once, then asks the server, and puts the old state back if
the server refuses. It returns nil — and does nothing — while a toggle for the same thread is
in flight or ran in the last 400 ms. Every change is announced as the thread family’s
.subscriptionChanged(parentMessageId:subscribed:).Next Steps
Customization Events
React to events in your own screens
Message List
The component most events update
Conversations
Stays in step with the events your screens emit
Groups
Follows group events from anywhere in the Kit