Android

CometChat SDK v1.6.0 now offers support for app development in Xamarin (beta). You can use Ready UI APIs using our Xamarin binding library.

Initial setup

Add reference to MessageSDKBinding.Droid.dll as shown in the images below:
step1

step2

You need to enable Multi-Dex support for your app, which can be done as shown in the image below:
step3

Once done, clean and build the project. This will add the Ready UI in your app.

Now you can include following classes in your MainActivity.cs

using Com.Inscripts.Cometchat.Sdk;
using Com.Inscripts.Utils;
using Com.Orm;

Add the following lines in your MainActivity.cs to start using Android SDK

LocalConfig.Initialize(this.ApplicationContext);
SugarContext.Init(this.ApplicationContext);

Once all this setup is done, you can use the ReadyUI functions in your app.

SetApiKey
You need to set the the api-key for your cloud subscription with SetApiKey() function. The syntax for this function is as follows:

SetApiKey(Context context, String API-KEY);

Login
You can login to CometChat using Login() methods. The syntax is as follows:

Login(Context context, String username, String password, ICallbacks callback);

Launch CometChat
After you have logged in successfully, you can launch CometChat by using LaunchCometChat() function. The syntax is as follows:

LaunchCometChat(Activity activity,ICallbacks callback);

Launch chatwindow
If you want to launch chat window of a specific user instead of launching whole CometChat then you can use LaunchChatWindow() function. The syntax is as follow:

LaunchChatWindow(bool flag,Activity activity, String userid, ICallback callback)
  • flag: Its a boolean flag. If set to true, then you can navigate back to userlist. If set to false, then you can only view the chat window.
  • userid: Pass the userid of the user with whom you wish to chat
  • Not finding what you need?

    The CometChat team is here to help!