CometChat Developer Documentation

Welcome Ninja!

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

Get Started    

Quick Start

The simplest voice, video and text chat SDK for your iOS app.

CometChat enables you to add voice, video and text chat to your iOS app in minutes! That's not all, CometChat has whiteboard, writeboard, real-time translation and more.

First, try out our sample chat app!

Before you add CometChat to your app, go ahead and download our sample app from GitHub. It gives you an indication of what to expect from CometChat.

Download Sample App (Swift)

Download Sample App (Objective C)

Once you download the sample app, update the License Key and API Key in the ViewController class in the project. (you can get these values from CometChat Admin Panel -> Settings -> API Key)

Please follow the steps mentioned in the file to build and run the app.

Next, use these steps to quickly add CometChat to your app

All set to add CometChat to your iOS app ?? Just follow these steps and get the chat up and running in your app.

Add the SDK to your project

  1. Add Dependencies Manually:

Click on Targets ā†’ Your app name ā†’ and then the ā€˜Build Phasesā€™ tab.
Expand ā€˜Link Binary With Librariesā€™ as given below and add the following frameworks.


  1. Add Dependencies Using CocoaPods:

You need to add the below lines to your project's podfile.

pod 'MessageSDKFramework' 
pod 'cometchat-ui' 
pod ā€˜Firebase/Authā€™
pod ā€˜Firebase/Databaseā€™
pod ā€˜Firebase/Messagingā€™
pod 'MessageSDKFramework' 
pod 'cometchat-ui' 
pod ā€˜Firebase/Authā€™
pod ā€˜Firebase/Databaseā€™
pod ā€˜Firebase/Messagingā€™

Cocoapods Setup

If you want to know about CocoaPods usage and installation you can refer to link below:
Also, please make sure you are using the latest version of Cocoapods.

  1. Add Linker Flag:

Click on Targets ā†’ Your app name ā†’ and then the ā€˜Build Settingsā€™ tab.
Scroll down to the ā€˜Linkingā€™ section, and double-click to the right of where it says ā€˜Other Linker Flagsā€™. Click on the ā€œ+ā€ button to add the following:

a. -ObjC

  1. Set Bitcode Enabled to NO:

Click on Targets ā†’ Your app name ā†’ and then the ā€˜Build Settingsā€™ tab. Scroll down to the 'Build Options' section, and set the 'Enable Bitcode' to 'NO'.

  1. Additional Setup for Swift:

In order for Xcode to use an Objective-C based framework in Swift, it needs to have a bridging header file. We have included a bridging header file in our framework. To link to it, you must open the build settings for your new target, and search for the Objective-C Bridging Header setting. You must then provide the path to the CometChat-Bridging-Header.h.

The path should be something similar to the one shown below :

Please Note

If you are using the iOS platform, please add the below five privacy permissions in the info.plist file which is necessary to access all the features. Please refer to the image below.

Initialize the Chat

The first step to launch the Chat in your iOS application is to initialize the CometChat module. You need to use the below method to do so:

let cometChat : CometChat = CometChat();
let apiKey: String= "xxxxxxxxxxxxxxxxxxxxxx";

self.cometChat.initializeCometChat("", licenseKey:licenseKey, apikey:apiKey, isCometOnDemand:true, 
 				success: {(response) in
        },failure:{(error) in

CometChat *cometChat = [[CometChat alloc]init];
NSString* apiKey = @"xxxxxxxxxxxxxxxxxxxxxx";

[cometChat initializeCometChat:@"" licenseKey:licenseKey apikey:apiKey isCometOnDemand:YES 
        success:^(NSDictionary *response) {

        } failure:^(NSError *error) {


The licenseKey and apiKey is available at CometChat Admin Panel -> Settings ->API Key.

Necessary Imports in case of Objective C:

Please make sure to import the below lines for using CometChat SDK:
import <MessageSDKFramework/CometChat.h>
import <cometchat-ui/readyUIFIle.h>

No imports are necessary in case of Swift

Login To Chat

The next step to launch the chat is to log in the user. CometChat provides a method loginWithUid() to log the user into chat. We have already added 5 demo users to your account with the UIDs SUPERHERO1,SUPERHERO2,SUPERHERO3,SUPERHERO4, and SUPERHERO5. You can use any of the users to log in. If you would like more information regarding User management, you can get it here.

let UID : String = "SUPERHERO1";

success:{(response) in                   
failure:{(error) in
NSString* UID = @"SUPERHERO1";

[cometChat loginWithUID:UID success:^(NSDictionary *response) {

    } failure:^(NSError *error) {


Keep in mind

The initializeCometChat and the loginWithUid methods must only be called once in the entire scope of the app. We suggest, you call the initializeCometChat method on app startup and call the loginWithUID() method once the user successfully logs in to your application.

Launch Chat

In order to launch the chat, you need to use the launchCometChat method.

let isFullScreen : Bool = true;
let readyUI: readyUIFIle = readyUIFIle();
self.readyUI.launchCometChat(isFullScreen, observer: self, userInfo: { (response) in
}, groupInfo: { (response) in
}, onMessageReceive: { (response) in
}, success: { (response) in
}, failure: { (error) in
}, onLogout: { (response) in
BOOL isFullScreen = YES;
readyUIFIle* readyUIFile = [[readyUIFIle alloc]init];
[readyUIFile launchCometChat:IsFullScreen observer:self userInfo:^(NSDictionary *response) {

    } groupInfo:^(NSDictionary *response) {

    } onMessageReceive:^(NSDictionary *response) {

    } success:^(NSDictionary *response) {

    } failure:^(NSError *error) {

    } onLogout:^(NSDictionary *response) {


CometChat also provides you with other options such as launch the chat window for a particular user directly or for a particular group. For more information, please check here.

You're all set! Go ahead and explore

Now that you have CometChat running in your app, you can tweak it further. Explore the other sections to learn more.

Quick Start

The simplest voice, video and text chat SDK for your iOS app.

Suggested Edits are limited on API Reference Pages

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