Displaying UI

Once the authentication is done, you can now launch the chat functionality directly into your app using the UI provided to you by the CometChat SDK.

The SDK provides you with three options to launch the UI. They are:

Launch CometChat

This option allows you to launch the entire chat functionality into your application. Once launched all the functionalities are handled by the SDK and you have a ready-to-go chat feature implemented in your android application.


launchCometChat(boolean,isFullScreen,function success(data){ },function error(data){ });

In Android,

 CCCometChat.launchCometChat(true, function success(data){ },function error(data){  });

In iOS,

 CCCometChat.launchCometChat("YES", function success(data){ },function error(data){  });

Parameters
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
success – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The success callback provide you with the following information as jsonObject

Method Details
successCallback This method is triggered once the request to launch CometChat is executed successfully
failCallback This is triggered when there is some issue when launching CometChat.
userInfoCallback This method is called when the user data is fetched from the server.
chatroomInfoCallback This method is triggered when the chatroom details are fetched by the server.
onmessagereceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.

Launch one-on-one user chat window

You can use this method to open the chat window for any particular user. This method launches the chat window for the user specified and allows you to chat with him/her easily.

launchCometChatWithID(final boolean isFullscreen,
final String groupUserId, final boolean isGroup,final boolean setBackButton, final LaunchCallbacks callbacks)

In Android,

CCCometChat.launchCometChatWithID(true,"12",false,false, function success(data){  },function error(data){  });

In iOS,

CCCometChat.launchCometChatWithID("YES","12","NO","NO", function success(data){  },function error(data){  });

Parameters
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
groupUserId – group id if you are launching a one-on-one window. User id of the user if u need to launch a user chat window.
isGroup – boolean value which needs to be set to true if you want to launch a one-on-one window. Else set it to false.
setBackButton – a boolean value which needs to be set to true if you want to have a back button one-on-one window. Else set it to false/NO.
callbacks – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The methods in the callback provide you with the following information

Method Details
successCallback This method is triggered once the request to launch CometChat is executed successfully
failCallback This is triggered when there is some issue when launching CometChat.
userInfoCallback This method is called when the user data is fetched from the server.
chatroomInfoCallback This method is triggered when the chatroom details are fetched by the server.
onMessageReceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.

Launch group chat window

This method can be used to open the chat window to any particular group.

launchCometChatWithID(final boolean isFullscreen,
final String groupUserId, final boolean isGroup, final boolean setBackButton, final LaunchCallbacks callbacks)

In Android,

CCCometChat.launchCometChatWithID(true,"21",true,false,function success(data){  },function error(data){  });

In iOS,

CCCometChat.launchCometChatWithID("YES","21","YES","NO",function success(data){  },function error(data){  });

Parameters
Activity – Instance of the activity.
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
groupUserId – group id if you are launching a group window. The user id of the user if u need to launch a user chat window.
isGroup – a boolean value which needs to be set to true if you want to launch a group window. Else set it to false.
setBackButton – a boolean value which needs to be set to true if you want to have a back button group window. Else set it to false.
callbacks – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The methods in the callback provide you with the following information

Method Details
successCallback This method is triggered once the request to launch CometChat is executed successfully
failCallback This is triggered when there is some issue when launching CometChat.
userInfoCallback This method is called when the user data is fetched from the server.
chatroomInfoCallback This method is triggered when the chatroom details are fetched by the server.
onMessageReceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.

**setBackButton : Works only in case of iOS and not in Android.

  • Was this helpful?
  • Yes   No