Skip to main content

Quick reply

Chat UI SDK supports preset reply phrases for direct channel and group channel screens.

tip

This feature is disabled by default.

Limitations

Each phrase supports up to 50 characters and displays across two lines. Longer phrases are truncated by default. To change this behavior, copy nc_ext_quick_reply_list_item_v2.xml from the SDK to your app module, modify the TextView attributes, and override the SDK layout.

Usage

Enable quick reply by setting default phrases before you initialize Chat UI SDK. If you skip this step, the feature will not work.

Java
NCChatUIConfig.featureConfig().enableQuickReply(new IQuickReplyProvider() {
@Override
public List<String> getPhraseList(ChannelType type) {
List<String> phraseList = new ArrayList<>();
phraseList.add("Hello.");
return phraseList;
}
});

To update the phrase list, call the method again. The new list replaces the existing phrases. In Chat UI SDK 5.6.2 and earlier, set phrases before you launch the channel screen or the screen will not reflect the latest phrases. In Chat UI SDK 5.6.3 and later, the screen refreshes immediately after you update phrases.

Java
NCChatUIConfig.featureConfig().enableQuickReply(new IQuickReplyProvider() {
@Override
public List<String> getPhraseList(ChannelType type) {
List<String> phraseList = new ArrayList<>();
phraseList.add("Hello.");
phraseList.add("You're welcome.");
phraseList.add("Have you eaten?");
return phraseList;
}
});

Customization

Intercept quick reply button click

When a user taps the quick reply button on the channel screen, the SDK displays the phrase list. To intercept this event, return true and implement your custom logic. To continue with the SDK default behavior, return false.

Java
default boolean onQuickReplyClick(Context context) {
return false;
}