Skip to main content

Input area

The Chat UI input area is managed by NCChatSessionInputBarControl, which integrates text input, voice, emoji, extension panels, and @mentions by default.

NCChannelViewController includes a built-in input area instance, typically accessed directly through chatSessionInputBarControl.

Configure input bar layout

The input bar supports multiple layout combinations, configurable through setInputBarType:style:.

Layout options

Layout patternEnum value
Voice switch - Input box - ExtensionsNC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER_EXTENTION
Extensions - Input box - Voice switchNC_CHAT_INPUT_BAR_STYLE_EXTENTION_CONTAINER_SWITCH
Input box - Voice switch - ExtensionsNC_CHAT_INPUT_BAR_STYLE_CONTAINER_SWITCH_EXTENTION
Input box - Extensions - Voice switchNC_CHAT_INPUT_BAR_STYLE_CONTAINER_EXTENTION_SWITCH
Voice switch - Input boxNC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER
Input box - Voice switchNC_CHAT_INPUT_BAR_STYLE_CONTAINER_SWITCH
Extensions - Input boxNC_CHAT_INPUT_BAR_STYLE_EXTENTION_CONTAINER
Input box - ExtensionsNC_CHAT_INPUT_BAR_STYLE_CONTAINER_EXTENTION
Input box onlyNC_CHAT_INPUT_BAR_STYLE_CONTAINER

Example

Objective C
- (void)viewDidLoad {
[super viewDidLoad];

[self.chatSessionInputBarControl
setInputBarType:NCChatSessionInputBarControlDefaultType
style:NC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER_EXTENTION];
}

To completely disable input, use NCChatSessionInputBarControlNoAvailableType.

Default input mode

Supported default input modes:

  • NCChatSessionInputBarInputText
  • NCChatSessionInputBarInputVoice
  • NCChatSessionInputBarInputExtention
Objective C
controller.defaultInputType = NCChatSessionInputBarInputText;

Common input area properties

PropertyDescription
inputTextViewText input field
switchButtonText/voice toggle button
recordButtonVoice recording button
emojiButtonEmoji button
additionalButtonExtension panel button
pluginBoardViewExtension panel view
emojiBoardViewEmoji panel view
draftCurrent draft text
maxInputLinesMaximum input lines (1-6)
mentionedInfoParsed @mention information
mentionedUserIdListList of mentioned user IDs
isMentionedEnabledWhether @mentions are enabled

Hide emoji button

Objective C
self.chatSessionInputBarControl.inputContainerView.hideEmojiButton = YES;

To completely disable system emoji, set this on the channel view controller:

Objective C
controller.disableSystemEmoji = YES;

Extension panel

The + panel in the input area is provided by NCPluginBoardView. The following built-in tags are exposed:

FeatureTag
AlbumPLUGIN_BOARD_ITEM_ALBUM_TAG
CameraPLUGIN_BOARD_ITEM_CAMERA_TAG
FilePLUGIN_BOARD_ITEM_FILE_TAG
Voice callPLUGIN_BOARD_ITEM_VOIP_TAG
Video callPLUGIN_BOARD_ITEM_VIDEO_VOIP_TAG
Voice inputPLUGIN_BOARD_ITEM_VOICE_INPUT_TAG
Business cardPLUGIN_BOARD_ITEM_CARD_TAG

Add custom extension items

Avoid using tags in the 1XXX range to prevent conflicts with SDK reserved tags.

Objective C
[self.chatSessionInputBarControl.pluginBoardView
insertItem:[UIImage imageNamed:@"plugin_custom"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_highlighted"]
title:@"Custom"
tag:20001];

Insert at specific position

Objective C
[self.chatSessionInputBarControl.pluginBoardView
insertItem:[UIImage imageNamed:@"plugin_custom"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_highlighted"]
title:@"Custom"
atIndex:0
tag:20001];

Update and remove extension items

Objective C
[self.chatSessionInputBarControl.pluginBoardView
updateItemWithTag:20001
normalImage:[UIImage imageNamed:@"plugin_custom_new"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_new_highlighted"]
title:@"New entry"];

[self.chatSessionInputBarControl.pluginBoardView removeItemWithTag:20001];

Handle extension item clicks

Objective C
- (void)pluginBoardView:(NCPluginBoardView *)pluginBoardView clickedItemWithTag:(NSInteger)tag {
if (tag == 20001) {
// Custom extension logic
return;
}

[super pluginBoardView:pluginBoardView clickedItemWithTag:tag];
}

@mentions and user selection

The input area exposes key interfaces for @mention functionality:

Objective C
self.chatSessionInputBarControl.isMentionedEnabled = YES;
[self.chatSessionInputBarControl addMentionedUser:userInfo];

By default, typing @ in a group channel triggers the SDK's user selection flow. To use a custom user selection page, override this method in your channel view controller and call the appropriate block when the selection finishes or is cancelled:

Objective C
- (void)showChooseUserViewController:(void (^)(NCChatUIUserInfo *selectedUserInfo))selectedBlock
cancel:(void (^)(void))cancelBlock;

For complete details about @mentions, see Message mentions.