Skip to main content
Enable users to start new 1:1 or group chats in your iOS app using CometChat’s UIKit for iOS by integrating the CreateConversationVC screen.

Overview

The CreateConversation component enables users to:
  • Browse CometChat users and groups via native list components
  • Search within users and groups
  • Toggle between “Users” and “Groups” tabs using a segmented control
  • Swipe between lists with a UIPageViewController
  • Navigate to MessagesVC upon selecting a user or group

Prerequisites

Before implementing this feature, ensure you have:
  • Completed Getting Started setup
  • CometChat UIKit v5+ installed via CocoaPods or Swift Package Manager
  • User authenticated with CometChatUIKit.login() before presenting this screen
  • A UINavigationController embedded in your flow
  • MessagesVC implemented to handle chat screens

Components

Integration Steps

Step 1: Present the Create Conversation Screen

Push CreateConversations to allow starting a chat:
This provides the entry point to the create-conversation flow. File reference: HomeScreenViewController.swift

Step 2: Set Up the User Interface

Build the segmented control and page view controller:
This initializes the UI elements and search integration. File reference: CreateConversations.swift

Step 3: Configure Segmented Control Navigation

Toggle between user and group lists when the segment changes:
This keeps the proper search bar and view in sync with the selected tab. File reference: CreateConversations.swift

Step 4: Handle Item Selection

Navigate to MessagesVC when a user or group is tapped:
This routes the user to the appropriate chat screen. File reference: CreateConversations.swift

Step 5: Manage Page View Transitions

Implement data source and delegate for smooth swiping:
This synchronizes the segmented control with page swipes. File reference: CreateConversations.swift

Customization Options

Segment Styling

Use CometChatTheme to customize tint and font:

Labels

Localize or rebrand “USERS” / “GROUPS” labels:
Adjust searchController.placeholder and styling:

Edge Cases

Error Handling

Feature Matrix

Users

Display and select users

Groups

Display and select groups

Conversations

View recent conversations

Sample App

Explore the complete create-conversation flow

UIKit Source

Browse the source for CreateConversationVC