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    

To add CometChat to your Xamarin Android/iOS app, please follow the below steps:

Add the NuGet packages for Android/iOS to your project

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.
e. Open your project settings and go to Build tab, then select iOS Build option.
f. Type --registrar:static in Additional mtouch arguments textbox for release and debug configuration
of iPhoneSimulator and iphone platform.
g. Click on Ok

Initialize the SDK

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

String siteurl = ""; 
String licenseKey = "COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX"; 
String apiKey = "xxxxxxxxxxxxxxxxxxxxxx"; 
Boolean isCometOnDemand = true;

CometChat cometChat = CometChat.GetInstance(this.ApplicationContext);

cometChat.InitializeCometChat(siteurl, licenseKey, apiKey, isCometOnDemand, new CometChatCallback((JSONObject obj) => {
   
   /*code block on success */
                        
},(JSONObject obj) => {
   
   /*code block on success */

}));
String siteurl = ""; 
String licenseKey = "COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX"; 
String apiKey = "xxxxxxxxxxxxxxxxxxxxxx"; 
Boolean isCometOnDemand = true;

cometchat = new CometChat();
readyUIFile = new readyUIFIle();
App.Configure();
User user = Auth.DefaultInstance.CurrentUser;
Database database = Database.DefaultInstance;
cometchat.InitializeCometChat(siteurl, licenseKey, apiKey, isCometOnDemand,(NSDictionary obj) =>{
if (obj != null){
       Console.WriteLine("Init Success " + obj.ToString());
  		/*code block on success*/
}
},(NSError obj) => {
if (obj != null)
{
       Console.WriteLine("Init Fail " + obj.ToString());
  			/*code block on fail*/
}
});

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.