Skip to main content
The iOS v6 Kit is one Swift package with three products — CometChatCore, CometChatSwiftUI and CometChatUIKit. An app adds one toolkit; CometChatCore and the Chat SDK come with it.

Module Structure

An app adds one toolkit — CometChatSwiftUI or CometChatUIKit. Both declare components with the same names (CometChatConversations, CometChatMessageList …), so one Swift file cannot import both.

The Layers

Both toolkits read the same stores, so they cannot disagree about what to show — only how it is drawn.

Value types

Stores publish value types, not SDK objects: ConversationsState.populated(entries, hasMore:), ChatConversation, ChatUser, ChatGroup, ChatMessage. They are Sendable, so they can leave an SDK callback queue under Swift 6. The store keeps the SDK objects alongside, keyed by id, so the toolkits’ callbacks hand you SDK types — onItemClick gives you a CometChatSDK.Conversation you can pass to the rest of your app.

State

Each store’s state is an enum of what the screen can show. The conversations list’s:

Behaviour hooks: policies

A store takes a policy — a value of closures, swappable without subclassing:
MessageListPolicy, MessageOptionsPolicy (who may edit, delete, report, message privately) and others follow the same shape. Stores are also non-final, for anything a policy does not cover.

Data Flow: End to End

Fetching conversations

  1. The component appears and asks its store to fetch.
  2. The store builds the SDK request (yours, if you passed a request builder) and fetches a page.
  3. The SDK answers on its own queue. The store maps the result to value types there, then hops to the main actor.
  4. The store publishes .populated(entries, hasMore:); the toolkit renders it.
  5. Scrolling to the end fetches the next page — .paginating, then .populated again.

Real-time updates

  1. The store registers SDK listeners under a unique id, and removes them when it goes.
  2. A message, receipt, typing indicator or presence change arrives from the SDK.
  3. The store applies its merge rule — move the row to the top, bump the unread count, show typing — and publishes a new state.

This user’s own actions

The SDK does not tell the Kit what this user did. So the component that acts announces it on CometChatEvents, and every other store listening updates:
  1. The user deletes a conversation in CometChatConversations.
  2. The store calls the SDK; on success it removes the row and emits conversationDeleted.
  3. Any other store showing that conversation hears the event and updates.
Actions taken on your screens must be announced by you — see Events.

Events (Cross-Component Communication)

There is one bus, CometChatEvents, with seven families: message, user, group, conversation, call, UI and thread. SwiftUI listens with view modifiers (.onCometChatUserBlocked { … }) or AsyncStreams (CometChatEvents.userEvents); UIKit has per-family buses and listener protocols (CometChatUserEvents, CometChatUserEventListener), which are views of the same bus. Delivery is on the main actor, in order.

Component-Level Overrides

Override points

1. Inject a store

InjectedStore.swift

2. Seed a store for previews and tests

A seeded store fetches nothing and registers no listeners:
Stores also take events: — pass CometChatEvents() for an isolated bus, so a test hears only its own events.

Component ↔ Store Mapping

Overview

Choosing a toolkit

Events

The event bus in full

Methods

CometChatSession

Upgrading from v5

What changed for v5 apps