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.
Add reference to MessageSDKBinding.Droid.dll as shown in the images below:
You need to enable Multi-Dex support for your app, which can be done as shown in the image below:
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)
Not finding what you need?
The CometChat team is here to help!