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    

Pre-requisites

Before you begin, make sure you have Cordova setup

The CometChat plugin supports Android (version 7 and higher) and iOS platform, which can be added to your project using the command:

ionic cordova platform add android
ionic cordova platform add ios
cordova platform add android
cordova platform add ios

To install the CometChat plugin in your project use the following command in your terminal/ command prompt from your project directory :

ionic cordova plugin add cordova-plugin-cccometchat
cordova plugin add cordova-plugin-cccometchat

This will download the CometChat plugin from NPM.

Since the CometChat plugin in iOS makes use of Cocoapods there might be some chances of improper loading of pods into your project.In such case, you can run pod update command in a terminal from iOS directory present under platforms of your project.

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

declare var CCCometChat : any;

Initialize the Plugin

Initialization binds the SDK to your app and syncs the various basic parameters required for the CometChat SDK to function.

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){});

Important

The initializeCometChat() must only be called once in the entire scope of the app. We suggest you call the initializeCometChat() method on app startup.

Please Note

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