Configuration guide
The Chat UI SDK global configuration provides easy-to-use feature settings to help you build chat applications quickly.
Configuration overview
The Chat UI SDK global configuration is organized into the following modules. You can review all available global configuration options in the corresponding files.
| Category | Description | API documentation | Source class |
|---|---|---|---|
| Feature configuration | Controls whether to enable message reference, disable emoji input, configure local notification sounds and vibration, and more. | FeatureConfig | ai.nexconn.chatui.config.FeatureConfig |
| Channel list configuration | Controls the avatar for each channel in the channel list, the number of channels to fetch per page, the channel list delayed refresh time, and more. | ChannelListConfig | ai.nexconn.chatui.config.ChannelListConfig |
| Channel configuration | Controls behaviors such as read receipts, deleting messages for everyone, message resend, merged forwarding, the default number of historical messages to fetch when entering a channel, and UI settings such as whether to display unread message bubbles and @ mention count indicators. | ChannelConfig | ai.nexconn.chatui.config.ChannelConfig |
| Gathered channel configuration | Controls the title, avatar, and other properties of gathered channels that aggregate multiple channels. | GatheredChannelConfig | ai.nexconn.chatui.config.GatheredChannelConfig |
| Notification configuration | Controls whether messages received in the foreground on non-channel pages are silent, the notification title type, the local notification category, and more. | NotificationConfig | ai.nexconn.chatui.notification.NotificationConfig |
Modify Chat UI configuration
Chat UI provides the NCChatUIConfig class as the entry point for modifying SDK global configuration.
When the NCChatUIConfig class is initialized, it first reads the default configuration from the nc_config.xml file. You can override the default configuration by creating a res/values/nc_config.xml file in your application directory, or you can dynamically modify the Chat UI configuration through the methods of the NCChatUIConfig class.
Configuration example code
// Disable the message reference feature
NCChatUIConfig.featureConfig().enableReference(false);
// Set the channel list delayed refresh time (prevents lag caused by excessive messages; this value cannot be set to 500)
NCChatUIConfig.channelListConfig().setDelayRefreshTime(1000);
// The avatar display for each item in the channel list defaults to rectangular. You can modify it to display with rounded corners. This method takes effect after the user sets an avatar. If no avatar is set, it cannot be modified to rounded corners using this method and defaults to a gray rectangular block.
NCChatUIConfig.featureConfig().setChatUIImageEngine(new GlideChatUIImageEngine() {
@Override
public void loadConversationListPortrait(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, BaseChannel channel) {
Glide.with(context).load(url)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(imageView);
}
});
// The avatar display for each message in the channel page defaults to rectangular. You can modify it to display with rounded corners. This method takes effect after the user sets an avatar. If no avatar is set, it cannot be modified to rounded corners using this method and defaults to a gray rectangular block.
NCChatUIConfig.featureConfig().setChatUIImageEngine(new GlideChatUIImageEngine() {
@Override
public void loadConversationPortrait(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, Message message) {
Glide.with(context).load(url)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(imageView);
}
});
// After modifying the `needDeleteRemoteMessage` property to `true`, Chat UI will delete both local and remote messages.
NCChatUIConfig.channelConfig().setNeedDeleteRemoteMessage(true);
// Set the foreground to not notify when receiving messages on non-channel pages.
NCChatUIConfig.notificationConfig().setForegroundOtherPageAction(
NotificationConfig.ForegroundOtherPageAction.Silent);
Check Chat UI configuration
Chat UI configuration takes effect on the next UI refresh or related operation. Except for a few notification configurations, we recommend completing most global configuration before calling NCChatUI.initialize().
Exceptions:
- The quick reply feature must be enabled before initialization (
NCChatUIConfig.featureConfig().enableQuickReply(...)), otherwise the feature will not take effect. notificationConfig().setCategoryNotification(...)should be set after initialization according to the source code comments.