Environment Setup

Pre-requisites:

Before you start with the integration of CometChat into your existing Android applications, kindly download the Xamarin SDK package from my.cometchat.com.

The package consists of three folders:

a. CometChat – This folder consists of the cometchatbindingapp.dll file
b. CometChatUI – This folder consists of the CometChatUIBinding.dll file
c. CometChat UI Binding – This folder consists of an Android project that we have created using our SDK. You can use the source code to make the necessary modifications to the app. Generate a new CometChatUIBinding.dll and import it in your project.

Steps to add CometChat to your application.

1. Add the cometchatbindingapp.dll and cometchatUIBinding.dll files to your project as references. To add the references to your Xamarin studio project, please follow the below steps.

a. Right Click on References and select Edit References.
b. Go to .NET Assembly Tab.
c. Browse to the location where you have stored the cometchatbindingapp.dll and cometchatUIBinding.dll files, and add the respective files.

2. Add the following packages to your app using NuGet Manager.

a. Xamarin.Android.Support.v4;
b. Xamarin.Android.Support.v7.AppCompat;
c. Xamarin.Android.Support.Design;
d. Xamarin.Android.Support.Core.UI;
e. Xamarin.Android.Support.Core.Utils;
f. Xamarin.Android.Glide;
g. Ikomobi.MaterialishProgress;

3. You need to enable the Multidex for your android application. Right-Click on the project and select Options.Move to Android build and enable the Multi-Dex option available under Packaging and Deployment in General Tab.

4. The next step is to add the necessary permissions to the AndroidMainfest.xml. Please add the below-mentioned permissions to your application’s AndroidManifest.xml file.


<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />

Please Note: For devices running Android 6.0 (API level 23) or above, users need to grant the permission to the app when the app is running and not before installing the app. This needs to be handled by you within the app else it may result in the application crashing. For more information regarding the dynamic permissions in android, please visit the following link

  • Was this helpful?
  • Yes   No