Skip to main content
Version: v4

Custom Interactive Message

The CustomInteractiveMessage class is used to create an interactive message that can be sent via CometChat. It extends the InteractiveMessage class from CometChat.

Constructor

NameTypeDescription
receiverIdstringThe ID of the receiver
receiverTypestringThe type of the receiver
jsonObjectJSONObjectThis parameter takes json object for interactiveData

Class Usage

How to create an instance of the CustomInteractiveMessage class:

JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("text", "custom Interactive message");
} catch (JSONException e) {
throw new RuntimeException(e);
}

CustomInteractiveMessage customInteractiveMessage = new CustomInteractiveMessage(receiverId,receiverType, jsonObject); //receiverType could be user/group

Send Custom Interactive Message

customInteractiveMessage.setSender(CometChatUIKit.getLoggedInUser());
customInteractiveMessage.setReceiver(user); // set Receiver user/group object

CometChatUIKit.sendCustomInteractiveMessage(customInteractiveMessage, false, new CometChat.CallbackListener<CustomInteractiveMessage>() {
@Override
public void onSuccess(CustomInteractiveMessage customInteractiveMessage) {

}
@Override
public void onError(CometChatException e) {
e.printStackTrace();
}
});