Skip to main content
Version: v4

Typing Indicators

Send a Typing Indicator

In other words, as a sender, how do I let the recipient(s) know that I'm typing?

Start Typing

You can use the startTyping() method to inform the receiver that the logged in user has started typing. The receiver will receive this information in the onTypingStarted() method of the MessageListener class. In order to send the typing indicator, you need to use the TypingIndicator class.

CometChat.startTyping(
receaverUid: "UID",
receiverType: CometChatReceiverType.user,
);

Stop Typing

You can use the endTyping() method to inform the receiver that the logged in user has stopped typing. The receiver will receive this information in the onTypingEnded() method of the MessageListener class. In order to send the typing indicator, you need to use the TypingIndicator class.

CometChat.endTyping(
receaverUid: "UID",
receiverType: CometChatReceiverType.user);
Custom Data

You can use the metadata field of the TypingIndicator class to pass additional data along with the typing indicators. The metadata field is a Map and can be set using the .metadata parameter of the TypingIndicator class. This data will be received at the receiver end and can be obtained using the same parameter.

Real-time Typing Indicators

In other words, as a recipient, how do I know when someone is typing?

You will receive the typing indicators in the onTypingStarted() and the onTypingEnded() method of the registered MessageListener class.

class Class_Name  with MessageListener {

//CometChat.addMessageListener("listenerId", this);

void onTypingStarted(TypingIndicator typingIndicator) {
// TODO: implement onTypingStarted
}


void onTypingEnded(TypingIndicator typingIndicator) {
// TODO: implement onTypingEnded
}


}

The TypingIndicator class consists of the below parameters:

ParameterInformation
senderAn object of the User class holding all the information related to the sender of the typing indicator.
receiverIdUID of the receiver. This is the ID of the group or the user the typing indicator is being sent to.
receiverTypeThis parameter indicates if the typing indicator is to be sent to a user or a group. The possible values are:
1. CometChatConstants.RECEIVER_TYPE_USER
2. CometChatConstants.RECEIVER_TYPE_GROUP
metadataA JSONObject to provider additional data