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 Cordova/Ionic app.

CometChat enables you to add voice, video and text chat to your Cordova/Ionic 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 Ionic Sample App

Download Cordova Sample App

Once you download the sample app, update the License Key and API Key in the home.ts file (Ionic) or index.js file (Cordova) in the project. (you can get these values from CometChat Admin Panel -> Settings -> API Keys).

Please follow the steps mentioned in the README.md 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 Cordova/Ionic app ?? Just follow these steps and get the chat up and running in your app.

Add the SDK to your project

  1. The CometChat plugin supports Android platform(version 7 and higher) and iOS platform. You can add the platforms to your project using the below commands:
ionic cordova platform add android
ionic cordova platform add ios
cordova platform add android
cordova platform add ios
  1. The next step is to add the CometChat plugin to your project. You can use the below command to do so:
ionic cordova plugin add cordova-plugin-cccometchat
cordova plugin add cordova-plugin-cccometchat

The CometChat plugin is available in the NPM store. The above command will download the plugin from the NPM store and add the same to your project.

In case of Ionic, please add the below line of code in your typescript file after the import statements:

declare var CCCometChat : any;

Once the above code is added to the typescript file. Both Ionic and Cordova function in the same way and no other changes are required.

Initialize the Chat

The first step to launch the chat in your Ionic/Cordova app is to initialize the Chat module. You can do so by calling the below method.

var licenseKey = "COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX";
var apiKey = "xxxxxxxxxxxxxxxxxxxxxx";

CCCometChat.initializeCometChat("",
                                licenceKey,
                                apiKey,
                                true,
                                successCallback(response{},
                                failCallback(response){});
var licenseKey = "COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX";
var apiKey = "xxxxxxxxxxxxxxxxxxxxxx";

CCCometChat.initializeCometChat("",
                                licenceKey,
                                apiKey,
                                true,
                                successCallback(response{},
                                failCallback(response){});

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

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 DEMO1,DEMO2,DEMO3,DEMO4, and DEMO5. You can use any of the users to log in. If you would like more information regarding User management, you can get it here.

var UID = "DEMO1"

CCCometChat.loginWithUID(UID,
     function success(data){
  			
		},
     function error(data){
  			 
	});
var UID = "DEMO1"

CCCometChat.loginWithUID(UID,
     function success(data){
  			
		},
     function error(data){
  			 
	});

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

The final step to get the chat up and running in your app is to launch the chat using the launchCometChat method.

var isFullscreen = true;
CCCometChat.launchCometChat(isFullScreen,
                            function success(data){ },
                            function error(data){  });
var isFullscreen = true;
CCCometChat.launchCometChat(isFullScreen,
                            function success(data){ },
                            function error(data){  });

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 Cordova/Ionic app.