AI Integration Quick Reference
AI Integration Quick Reference
Overview
- Your screen calls the SDK to block or unblock.
- You set the user’s
blockedByMeand emituserBlocked/userUnblocked. - The Kit reacts: Conversations drops the chat on a block, Users and the message header redraw the user, and the composer stops sending typing indicators.
- Your chat screen swaps the composer for an “Unblock” bar while you have blocked the user.
Prerequisites
- The Kit is set up and a user is logged in — see Getting Started.
- A one-to-one chat screen with
CometChatMessageHeader,CometChatMessageListandCometChatMessageComposer.
Components
Integration Steps
1. Bridge the SDK calls
The SDK calls back on its own queue. Bridge it from anonisolated function so the callback
never runs as main-actor code:
BlockActions.swift
2. Block from your details screen, and announce it
After the SDK succeeds, mark the user and emit the event. Without the event the conversation stays in Conversations and the header shows the user as unblocked.- SwiftUI
- UIKit
UserDetailsView.swift
Ask before blocking. The CometChat sample apps confirm with “Block this contact?” and then
show a toast with the result.
3. Swap the composer for an unblock bar
The composer does not hide itself. While you have blocked the user, show your own bar in its place, and follow the block from anywhere in the app through the event:- SwiftUI
- UIKit
BlockAwareComposer.swift
4. Hide calls while either side has blocked
The message header hides its call buttons only when you ask. Use both flags — a block either way should stop calls:- SwiftUI
- UIKit
Implementation Flow
- The user taps Block on your details screen and confirms.
CometChat.blockUserssucceeds; you setblockedByMeand emituserBlocked.- Conversations removes the chat, Users and the header redraw, your chat shows the unblock bar.
- Unblock reverses it with
unblockUsersanduserUnblocked; the composer returns.
Edge Cases
Group vs. User-Level Differences
Blocking is between two users. It does not remove anyone from a group: in a group chat you keep seeing a blocked user’s messages. To keep someone out of a group, ban or kick them — see Group Chat.Feature Matrix
Next Steps
Events
Every event your screens must announce
Message Composer
The composer’s options
Block Users (SDK)
The SDK calls in full
All Guides
Browse the other guides