Skip to main content
Give users Slack-style control over thread noise. A user can subscribe to a message thread to be notified of future replies, or unsubscribe from it to mute it. Users are automatically subscribed to a thread when they start it, reply in it, or are @-mentioned in it — and they can explicitly subscribe to any parent message, even one that has no replies yet. The SDK also exposes the list of threads a user participates in, so you can build a thread inbox. Let’s see how to work with thread subscriptions in CometChat’s iOS SDK.
Thread subscription builds on Threaded Messages. A thread is identified by the ID of its parent message — there is no separate thread ID.

Subscribe to a Thread

To subscribe to a thread, use the subscribeToThread method with the ID of the thread’s parent message. The call is idempotent — subscribing to a thread the user is already subscribed to succeeds silently. Subscribing to a message with zero replies is allowed; the user will be notified when the first reply arrives.

Unsubscribe from a Thread

To unsubscribe from a thread, use the unsubscribeFromThread method. This too is idempotent — unsubscribing from a thread the user is not subscribed to succeeds silently.
Unsubscribing is not sticky. If the user replies in the thread again, or is @-mentioned in it, they are automatically re-subscribed. Do not promise users “you won’t be notified about this thread again”.

Get the Subscription State

threadSubscriptionState(forParentMessageId:) returns the logged-in user’s subscription state for a thread synchronously — it never makes a network call, never throws, and is safe to call from your UI while rendering.
The state is a deliberate tri-state, not a boolean:
Render UNKNOWN as the unsubscribed state (an enabled “Subscribe” control) — never as a spinner or a disabled control. The state is kept in an in-memory, per-login-session cache; it is cleared on login and logout, and nothing is persisted to disk.

Fetch the Threads a User Participates In

To build a thread inbox — one row per thread the user is part of — create a ThreadsRequest using the ThreadsRequestBuilder. The list is the union of threads the user started, replied in, was mentioned in, or explicitly subscribed to. Every returned row is, by definition, a thread the user is subscribed to: participation is subscription, and unsubscribing removes the row.
Call fetchNext repeatedly to page forward; hasMore() tells you whether more pages exist. A ThreadsRequest is single-use and forward-only — there is no fetchPrevious. To refresh the list from the top, build a new request from the builder and replace your list with its results.

The MessageThread Model

Each row is a MessageThread:
To order rows in your UI, sort on lastReply?.sentAt, falling back to parentMessage?.sentAt for zero-reply threads — not on updatedAt.
The list starts empty for every user when the feature launches — it fills up as users reply, get mentioned, and subscribe to threads. There is no historical backfill.

Real-time Thread Events

Conform to CometChatThreadDelegate to keep your UI in sync as subscription state changes and replies arrive.
Both callbacks are optional. The events carry:
  • onThreadSubscriptionChanged fires when the logged-in user’s subscription state for a thread changes on this device — after a successful subscribe/unsubscribe call, or after a threaded send auto-subscribes them.
  • onThreadReplyReceived fires for every incoming threaded message and for the user’s own successful threaded sends. Use it to bump reply counts and re-sort your thread list.
A subscribe or unsubscribe performed on the user’s other device does not currently produce a real-time event on this one — the state self-corrects on the next message fetch, so refresh your thread list when the app returns to the foreground.

Notification Preferences

The notification preference for replies gains a new value so users can be notified only for threads they are subscribed to: SUBSCRIBE_TO_SUBSCRIBED_THREADS in the replies options. See Notification Preferences for how to read and update a user’s preferences.

Error Handling