CometChat Go 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 Xamarin.Forms app.

CometChat enables you to add voice, video and text chat to your Xamarin.Forms 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 Xamarain.Forms Sample App

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

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

All set to add CometChat to your Xamarin.Forms app? Just follow these steps and get CometChat up and running in your app.

Add the NuGet packages for Android and iOS platforms to your project.

The first step is to add the NuGet packages for both Android and iOS.

For Android:
a. Expand the Android project.
b. Right-click on the packages folder and click on Add packages.
c. Search for Xamarin.Android.CometChat package and add it to your project.
d. Search for Xamarin.Android.CometChat.UI package and add it to your project.

For iOS:
a. Expand the iOS project.
b. Right-click on the packages folder and click on Add packages.
c. Search for Xamarin.iOS.CometChat package and add it to your project.
d. Search for Xamarin.iOS.CometChat.UI package and add it to your project.

Add the helper classes to your main project.

You will need to add the below helper classes to your main project:

  1. Callbacks.cs
  2. CometChatFormCallback.cs
  3. CometChatInterface.cs
  4. CometChatLaunchCallbacks.cs
  5. LaunchCallbackImplementation.cs

Add the implementation classes for the respective Android and iOS projects:

For Android:

  1. CometChatImplementation.cs

For IOS:

  1. CometChatImplementation.cs.

Initialize the Chat

Once all the above steps are done, the first step to launch the Chat in your Android application is to initialize the CometChat module. You need to use the below method to do so:

String apiKey = "xxxxxxxxxxxxxxxxxxxxxx"; 

 var cometchat = DependencyService.Get<CometChatInterface>();

cometchat.initializeCometChat("", licenseKey, apiKey, true, new Callbacks(success => initializeSuccess(success), fail => initializeFail(fail)));

Log in 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.

var cometchat = DependencyService.Get<CometChatInterface>();
cometchat.loginWithUID(UID, new Callbacks(success => loginSuccess(success), fail => loginFail(fail)));


Keep in mind

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

Launch Chat

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

var cometchat = DependencyService.Get<CometChatInterface>();
 Boolean isFullScreen = true;

cometchat.launchCometChatWindow(isFullScreen, new LaunchCallbackImplementation(
successObj => OnSuccessCall(successObj),
fail => OnFailCall(fail),
onChatroomInfo => OnChatroomInfo(onChatroomInfo),
onError => OnError(onError),
onLogout => OnLogout(onLogout),
onMessageReceive => OnMessageReceive(onMessageReceive),
onUserInfo => OnUserInfo(onUserInfo),
onWindowClose => OnWindowClose(onWindowClose)));

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.


Please Note

This is just an example of how we have implemented CometChat Methods. In case you wish to do it in your own way, you are free to do so. You can refer to the sample app provided by us.

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.


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.

Updated 2 years ago

Quick Start

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

Suggested Edits are limited on API Reference Pages

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