Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-release-ios-chat-uikit-v5-1-2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The FormMessage class is used to create an interactive form message that can be sent via CometChat. It extends the InteractiveMessage class from CometChat.
Constructor
| Name | Type | Description |
|---|
| receiverId | string | The ID of the receiver |
| receiverType | string | The type of the receiver |
| title | string | The title of the form |
| formFields | Array<ElementEntity> | The fields of the form |
| submitElement | ButtonElement | The submit button of the form |
Class Usage
How to create an instance of the FormMessage class:
List<ElementEntity> elementEntities = new ArrayList<>();
//here we have created the object to display the TextInput into the form
TextInputElement textInputElement1 = new TextInputElement("element1", "Name");
TextInputElement textInputElement2 = new TextInputElement("element2", "Last Name");
TextInputElement textInputElement3 = new TextInputElement("element3", "Address");
textInputElement3.setMaxLines(5);
elementEntities.add(textInputElement1);
elementEntities.add(textInputElement2);
elementEntities.add(textInputElement3);
//here we have created the navigation action which will executated on a click of button
URLNavigationAction urlNavigationAction = new URLNavigationAction("https://www.cometchat.com/");
ButtonElement submitElement = new ButtonElement("idSubmit", "submit", urlNavigationAction);
submitElement.setDisableAfterInteracted(true);
FormMessage formMessage = new FormMessage(receiverId, receiverType, elementEntities, submitElement);
formMessage.setTitle("Socity Survey");
formMessage.setAllowSenderInteraction(true); // this will confirm if sender can interact with that form or not
formMessage.setSender(CometChatUIKit.getLoggedInUser());
formMessage.setSentAt(System.currentTimeMillis() / 1000);
formMessage.setReceiver(user); // set Receiver user/group object
CometChatUIKit.sendFormMessage(formMessage, false, new CometChat.CallbackListener<FormMessage>() {
@Override
public void onSuccess(FormMessage formMessage) {
}
@Override
public void onError(CometChatException e) {
e.printStackTrace();
}
});