Skip to main content
Enable users to start a private one-on-one chat with a group member directly from a group chat screen using CometChat’s UIKit for iOS.

Overview

The Message Privately feature allows users to long-press a message in a group chat and select Message Privately to transition into a private conversation with the original sender. This streamlines side discussions and follow-ups without requiring manual user searches.

Prerequisites

Before implementing this feature, ensure you have:
  1. Completed Getting Started setup
  2. CometChat UIKit v5+ installed
  3. User logged in with CometChatUIKit.login()

Components

Integration Steps

Step 1: Control Option Visibility via ViewModel

Dynamically show or hide Message Privately based on app context:
This ensures the option only appears when appropriate (e.g., based on user permissions). File reference: CometChatMessageList.swift

Step 2: Handle Private Chat Navigation

Retrieve the sender and initiate a private 1-on-1 chat:
This automates the transition from group context to private conversation. File reference: CometChatMessageList.swift

Implementation Flow

Customization Options

Styling

Override CometChatMessageOption UI elements:

Availability

Control visibility via the view model:

Extend Options

Add additional actions in MessageDataSource.getMessageOptions(for:):

Edge Cases

Error Handling

Additional Notes

  • This feature is only available in group chat screens (CometChatMessageList)
  • The option is hidden automatically in direct/private chat views

Feature Matrix

Sample App

Explore this feature in the CometChat SampleApp

UIKit Source

Browse the message list component

Users

Display and manage users

Conversations

View and manage conversations

Group Members

View group membership