CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Quick Start

Learn how to add CometChat to your iOS app in minutes.

This guide demonstrates how to add chat to an iOS application using CometChat. Before you begin, we strongly recommend you read the Key Concepts guide.

I want to explore sample apps.

Import the app into Xcode and follow the steps mentioned in the file.

Download Swift Chat App

Download Obj-c Chat App

View on Github

Get your Application Keys

Signup for CometChat and then:

  1. Create a new app
  2. Head over to the API Keys section and note the Auth Key, App ID & Region


Minimum Requirement

  1. Xcode 11.4 (or Higher)
  2. iOS 11 or higher

Add the CometChat Dependency


We recommend using CocoaPods, as they are the most advanced way of managing iOS project dependencies. Open a terminal window, move to your project directory, and then create a Podfile by running the following command.



  1. CometChatPro SDK supports installation through Cocoapods only. Currently, we are supporting Xcode 11.4 and higher.

  2. CometChatPro SDK includes video calling components. We suggest you run on physical devices to avoid errors.

$ pod init

Add the following lines to the Podfile.

platform :ios, '11.0'

target 'MyApp' do
  pod 'CometChatPro', '2.1.2'

And then install the CometChatPro framework through CocoaPods.

$ pod install

Always get the latest version of CometChatPro by command.

$ pod update CometChatPro

Setup Bitcode

In case if you are using the CometChat Pro SDK version greater or equal to 2.0.8 then you can set the Enable Bitcode setting to YES present in build settings in your XCode project.


If you are using CometChat Pro SDK having the version less than 2.0.8, then you need to set Enable Bitcode to NO

Swift Standard Libraries

CometChatPro framework build on Swift, you have to ensure the required libraries are embedded. This can be done by setting the “Always Embed Swift Standard Libraries” checkbox in your target’s build settings to “Yes”:

Set Header Search Path

Set the Header Search Paths to $SDKROOT/usr/include/libxml2.

Initialize CometChat

The init() method initializes the settings required for CometChat. We suggest you call the method on app startup preferably in the didFinishLaunchingWithOptions: method of the AppDelegate class.

import CometChatPro

class AppDelegate: UIResponder, UIApplicationDelegate{
   var window: UIWindow?
   let appId: String = "ENTER APPID"
   let region: String = "ENTER REGION CODE"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

let mySettings = AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region: region).build()
  CometChat(appId: appId ,appSettings: mySettings,onSuccess: { (isSuccess) in
            if (isSuccess) {
                print("CometChat Pro SDK intialise successfully.")
        }) { (error) in
                print("CometChat Pro SDK failed intialise with error: \(error.errorDescription)")
        return true
#import <CometChatPro/CometChatPro-Swift.h>

@interface AppDelegate ()


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  NSString *region = @"REGION";
  NSString *appID = @"YOUR_APP_ID";
    AppSettingsBuilder *appSettingBuilder = [[AppSettingsBuilder alloc]init];
    AppSettings *appSettings = [[[appSettingBuilder subscribePresenceForAllUsers]setRegionWithRegion:region]build];
    [[CometChat alloc]initWithAppId: appID appSettings:appSettings onSuccess:^(BOOL isSuccess) {
        NSLog(isSuccess ? @"CometChat Initialize Success:-YES" : @"CometChat Initialize Success:-NO");
    } onError:^(CometChatException * error) {
        NSLog(@"Error %@",[error errorDescription]);
    return YES;

Make sure you replace the APP_ID with your CometChat App ID in the above code.

Register and Login your User

Once initialisation is successful, you will need to create a user.
To create users on the fly, you can use the createUser() method. This method takes an User object and the API Key as input parameters and returns the created User object if the request is successful.

let newUser : User = User(uid: "user1", name: "Kevin") // Replace with your uid and the name for the user to be created.
let apiKey = "API_KEY" // Replace with your API Key.
CometChat.createUser(user: newUser, apiKey: apiKey, onSuccess: { (User) in
      print("User created successfully. \(User.stringValue())")
  }) { (error) in
     print("The error is \(String(describing: error?.description))")

Once initialization is successful, you will need to log the user into CometChat using the login() method.

The login method needs to be called in the following scenarios:

  1. When the user is logging to the App for the first time.
  2. If the CometChat.getLoggedInUser() function returns nil.



Kindly, make sure you add the check of CometChat.getLoggedInUser() function in your app where you check the App's user login status. In case it returns nil then you need to call the Login method inside it.

let uid    = "SUPERHERO1"
let apiKey = "YOUR_API_KEY"

if CometChat.getLoggedInUser() == nil {

    CometChat.login(UID: uid, apiKey: apiKey, onSuccess: { (user) in

    print("Login successful : " + user.stringValue())

    }) { (error) in

    print("Login failed with error: " + error.errorDescription);


NSString *uid    = @"SUPERHERO1";
NSString *apiKey = @"YOUR_API_KEY";

if ([CometChat getLoggedInUser == nil]){
[CometChat loginWithUID:uid apiKey:apiKey onSuccess:^(User * user) {
    // Login Successful
    NSLog(@" Login Successful :%@",[user stringValue]);
} onError:^(CometChatException * error) {
    // Login error
    NSLog(@" Login failed with exception: %@",[error errorDescription]);

Make sure you replace the API_KEY with your CometChat API Key in the above code.


Sample Users

We have set up 5 users for testing having UIDs: SUPERHERO1, SUPERHERO2, SUPERHERO3, SUPERHERO4 and SUPERHERO5.

The login() method returns the User object containing all the information of the logged in user.


UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.

Add UI Kit Library

To integrate the UI Kit library inside your app. Kindly follow the below steps:

  1. Simply clone the UI Kit Library from the ios-chat-ui-kit repository or download it.
  1. After cloning the repository, Navigate to the Library folder and Add the folder inside your app.
  1. Make sure you've selected ✅ Copy items if needed as well as 🔘 Create group options while adding the Library inside your project.

  2. If the Library is added successfully, all folders are highlighted in yellow color.

Launch UI Unified

UI Unified is a way to launch a fully working chat application using the UI Kit. In UI Unified all the UI Screens and UI Components working together to give the full experience of a chat application with minimal coding effort.

To use UI Unified user has to launch CometChatUnified class. CometChatUnified is a subclass of UITabbarController.

You can launch the CometChatUnified class using the below code snippet.


let unifiedUI = CometChatUnified()
unifiedUI.setup(withStyle: .fullScreen)
self.present(unifiedUI, animated:true, completion:nil)

CometChatUnified provides below method to present this activity:

Sr. No.



setup(withStyle: .fullScreen)

This will present the window in two modes:

To receive real time call events, user has to register for them in App Delegate class.

CometChatCallManager().registerForCalls(application: self)

You can also use individual UI Screens or UI Components present in UI Kit.

You can Customize UI Kit as per your requirement using UIKit Settings .

Updated 8 days ago

What's Next

The UI Kit has been developed to help developers of different levels of experience to build a chat application in a few minutes to a couple of hours.

UI Kit

Quick Start

Learn how to add CometChat to your iOS app in minutes.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.