Threads
Message threading is a feature that allows users to reply to each other's messages in a channel. Users can ask questions, give feedback or add context to a specific message without interrupting the conversation flow. A message thread refers to a group of messages and their replies. Sendbird UIKit supports two reply types: quote reply and threads. Threads allow users to start a separate conversation in a new thread screen when responding to a message. The reply message is also sent to the channel in the message list component.
Limitations
Threads currently have the following limitations:
- UIKit message threading is available for group channels and supergroup channels only.
- Sendbird UIKit only supports 1-depth threads, meaning you can't reply to messages that are already thread replies to a parent message.
How to use
To turn on thread mode, set the reply filter to THREAD
:
Set ThreadReplySelectType
You have the option to set ThreadReplySelectType
to PARENT
or THREAD
. This enum function allows you to direct your users to view either the parent message or the message thread when they tap on a reply in the group channel screen.
Reply to messages
Users can reply to messages in a group or supergroup channel. To do so, long tap on the message you wish to reply to in the MessageListComponent
of ChannelModule
. Then, a message menu appears. Once the Reply in thread button is selected, users can start replying in a new thread in MessageThreadModule
. A message that already has a reply is called a parent message and the replied message is called a reply. Both parent messages and replies can be either a user message or file message.
The Message menu contains an Emoji reaction bar, a Copy button, and a Reply in thread button. To view the menu, long tap on a message in the channel view. Then, tap Reply in thread in the menu to reply to the selected message in a new thread. If you reply with a user message, the sendUserMessage(UserMessageParams params)
method of MessageThreadFragment
is invoked and a new thread is created. When replying with a file message, the SendFileMessage(Uri uri)
method of MessageThreadFragment
is invoked.
Like quote reply, threads only allow 1-depth threads. This means that users can’t reply to messages that are already thread replies to a parent message. The Reply in thread button of a message that’s already a thread reply appears as deactivated. Similarly, the Delete button of a parent message that has one or more replies in a thread appears as deactivated. To delete the parent message, its thread replies must be deleted first.
The UI for threads in the Message menu can be customized through the string resource and icon resource.
The Reply in thread text in the Message menu can be customized through the string resource. The string resource is a set of strings used to compose a view. It's a res/strings.xml
file containing UIKit-defined string values.
The following table shows a customizable reply in thread icon.
Icon name | Image | Description |
---|---|---|
icon_thread | An icon used to indicate Reply in thread. |
Message thread
Once the current user taps Reply in thread in the Message menu, they can start a new thread in the MessageThreadModule
of MessageThreadActivity
. The message thread screen is composed of four components: message thread header, thread list, message thread input, and thread list status.
The header component shows the title of the message thread screen, which says Thread by default. Below the title, there's a text button that indicates the name of the channel that the thread belongs to. When a user taps on the button, they can view the corresponding parent message in the group channel screen.
In the thread list component, the parent message and its replies are displayed in a chronological order while in the message thread input component, the user can send either a text message or a file message as a reply to the parent message. The placeholder text in the message thread input field changes depending on whether the parent message has an existing thread or not. If the parent message already has one or more thread replies, the default placeholder text shows as Reply to thread. If the parent message has no existing replies, the placeholder text shows as Reply in thread.
Customize the UI in message thread screen
You can customize the UI for threads in MessageThreadHeaderComponent
and MessageThreadInputComponent
of MessageThreadModule
using the string resource.
String resource for header
The channel name below the message thread title in the header component can be customized through the string resource.
String resource for message thread input
The Reply in thread and Reply to thread placeholder texts in the message thread input component can be customized through the string resource.
Show replies
Users can view reply messages in both the message thread screen and the group channel screen because all replies sent to a thread also get sent to the channel automatically. In the message thread screen, replies are shown chronologically in the ThreadListComponent
of MessageThreadModule
with the current user’s replies shown on the right and channel members’ replies shown on the left of the screen by default. In the group channel screen, the parent message has a ThreadInfoView
that’s internally implemented in the UIKit to show the number of replies it has and the profile images of the users who replied to the message. The replies sent to the channel are displayed the same way as quoted messages in quote reply mode.
Thread list
In the message thread screen, the parent message is displayed below the MessageThreadHeaderComponent
of MessageThreadModule
. Its reaction emojis and the number of replies in the thread are also shown below. In the ThreadListComponent
of MessageThreadModule
, the parent message and a list of all replies to that message are shown in a chronological order. Both the parent message and the reply can be a text or file message. By default, the replies sent by the current user are displayed on the right side of the screen and the message bubble is purple. In the StatusComponent
of MessageThreadModule
, you can also customize the text that indicates the thread list couldn't be retrieved because there was an error while requesting the data.
Customize the UI in thread list
You can customize the UI for threads in the ThreadListComponent
of MessageThreadModule
when a reply is sent to the thread.
String resource for thread list
The number of thread repiles shown in the thread list component and the error text displayed in the status component can be customized through the string resource.
Group channel
In the group channel screen, every parent message has a ThreadInfoView
that displays the number of thread replies and up to four profile images of users who responded in the thread. Since all replies sent to a thread also get sent to the channel automatically, the thread replies are shown in the channel as quoted messages in quote reply mode. Users can view these replies through BaseQuotedMessageView
, MyQuotedMessageView
, and OtherQuotedMessageView
. These views are internally implemented classes in Sendbird UIKit used to display the different types of reply messages on the screen. Both MyQuotedMessageView
and OtherQuotedMessageView
inherit the properties and methods of BaseQuotedMessageView
. The BaseQuotedMessageView
shows the parent message and a text that indicates a user replied to another channel member.
There are two types of views in which the thread reply is displayed: MyQuotedMessageView
and OtherQuotedMessageView
. When the current user replies to a message in the channel, the parent message is shown through MyQuotedMessageView
. When another channel member replies to a message in the channel, the parent message is displayed through OtherQuotedMessageView
.
Customize the UI in group channel screen
You can customize the UI for threads in ThreadInfoView
, MyQuotedMessageView
, and OtherQuotedMessageView
using the string resource and icon resource.
String resource
The number of thread replies shown in ThreadInfoView
and the text that indicates a user replied to another user in MyQuotedMessageView
and OtherQuotedMessageView
can be customized through the string resource.
Icon resource
The following table shows the icon to the left of the text in MyQuotedMessageView
and OtherQuotedMessageView
, which can be customized through the icon resource.
Icon name | Image | Description |
---|---|---|
icon_reply_filled | An icon used to indicate that a user replied to another user’s message in a channel. |