type
and category
of a message, the appearance and behavior of the header, content, and footer sections of the message bubble,
setType()
you can set the type of CometChatMessage, This will map your MessageTemplate to the corresponding CometChatMessage. You can set the MessageTemplates Type using the following code snippet.
.setCategory()
you can set the category of a MessageTemplate. This will create a MessageTemplate with the specified category and link it with a CometChatMessage of the same category.
Please refer to our guide on Message Categories for a deeper understanding of message categories.
template.headerView
method allows you to assign a custom header view to the MessageBubble. By default, it is configured to display the sender’s name.
template.contentView
method allows you to assign a custom content view to the MessageBubble. By default, it displays the Text Bubble, Image Bubble, File Bubble, Audio Bubble, or Video Bubble, depending on the message type.
template.footerView
method allows you to assign a custom Footer view to the MessageBubble. By default, it displays the receipt and timestamp.
template.bottomView
method allows you to assign a custom Bottom view to the MessageBubble.By defuault is has buttons such as link previews or a ‘load more’ button for long messages.
template.bubbleView
method allows you to assign a custom Bubble view to the MessageBubble. By default, headerView, contentView, and footerView together form a message bubble.
template.options
lets you set the list of actions that a user can perform on a message. This includes actions like reacting to, editing, or deleting a message.
CometChatMessageBubble
Component for example here so to apply Template to Messages you will have to use MessageList component.
By utilizing this code snippet, you will retrieve text templates
.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.headerView
method of MessageTemplate allows you to add custom views to the header of your message bubbles. In the example below, we will add a custom UIView custom_header_view
to the header view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.contentView
method of MessageTemplate allows you to add a custom view to the content of your message bubbles. In the example below, we will add a custom custom_message_view_file
to the content view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.bottomView
method of MessageTemplate allows you to add a custom button view to your message bubbles. In the example below, we will add a custom UIView custom_bottom_view_file
to the bottom view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.footerView
method of MessageTemplate allows you to add a footer view to your message bubbles. In the example below, we will add a custom UIView file custom_footer_view
to the bottom view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller. template.bubbleView
method of MessageTemplate allows you to add a bubble view to your message bubbles. In the example below, we will add a custom UIView custom_bubble_view
to the bubble view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.options
method in the MessageTemplate allows you to customize the options that appear in the action sheet when a message is long-pressed. By default, CometChat UIKit provides a set of options like “Edit”, “Share”, “Translated message”, and “Delete”.
However, if you wish to override or modify these options, you can use the template.options
method and pass a list of getMessageOptions
. This list of options will replace the default set.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.template.statusInfoView
method of MessageTemplate enables you to add a status info view to your message bubbles. This is a user-defined component used to display the statusInfo view, which shows the timestamp and read-receipt of the message.
In the example below, we will integrate a custom UIView file named custom_status_view
into the status info view of every text message in the MessageList.
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.