Skip to main content

Typing indicator

The typing indicator lets users see when someone else is composing a message in a channel. Direct channels support sending typing status; other channel types use the channel event handler to observe incoming typing events.

Send typing status

Call sendTypingStatusWithTypingMessageType: on an NCDirectChannel instance to broadcast the current user's typing state:

swift
import NexconnChatSDK
guard let channel = DirectChannel(channelId: "targetUserId") else { return }
channel.sendTypingStatus(typingMessageType: MessageType.text)
ParameterTypeDescription
typingMessageTypeNSString *The message type being typed. Pass a value from NCMessageType, e.g., NCMessageType.text.
tip

Call this method each time the user's input changes. The server automatically expires the typing state after a short interval if no update is sent.

Listen for typing status changes

Register an NCChannelHandler to receive typing status notifications from other users:

swift
import NexconnChatSDK
final class MyChannelHandler: NSObject, ChannelHandler {}

let channelHandler = MyChannelHandler()
NCEngine.addChannelHandler(identifier: "MyChannelHandler", handler: channelHandler)

Implement the NCChannelHandler protocol method:

swift
import NexconnChatSDK
func onTypingStatusChanged(_ event: TypingStatusChangedEvent) {
for info in event.userTypingStatus {
print("User \(info.userId) is typing in channel \(event.channelIdentifier.channelId)")
}
}

NCChannelUserTypingStatusInfo properties:

PropertyTypeDescription
userIdNSString *ID of the user who is typing.
typingMessageTypeNSString *Message type being typed.
sentTimeint64_tTyping status message sent time in milliseconds.