Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

// Start typing indicator
val typingIndicator = TypingIndicator("UID", CometChatConstants.RECEIVER_TYPE_USER)
CometChat.startTyping(typingIndicator)

// Stop typing indicator
CometChat.endTyping(typingIndicator)

// Listen for typing events
CometChat.addMessageListener("LISTENER_ID", object : MessageListener() {
    override fun onTypingStarted(indicator: TypingIndicator) { }
    override fun onTypingEnded(indicator: TypingIndicator) { }
})

Send a Typing Indicator

Start Typing

Use startTyping() with a TypingIndicator object to notify the receiver that you’re typing.
TypingIndicator typingIndicator = new TypingIndicator(UID, CometChatConstants.RECEIVER_TYPE_USER);

CometChat.startTyping(typingIndicator);

Stop Typing

Use endTyping() to notify the receiver that you’ve stopped typing.
TypingIndicator typingIndicator = new TypingIndicator(UID, CometChatConstants.RECEIVER_TYPE_USER);

CometChat.endTyping(typingIndicator);
Use setMetadata() on TypingIndicator to pass additional custom data. Retrieve it with getMetadata() on the receiver side.

Real-time Typing Indicators

Use onTypingStarted and onTypingEnded in MessageListener to receive typing events.
CometChat.addMessageListener("Listener 1", new CometChat.MessageListener() {
@Override
public void onTypingStarted(TypingIndicator typingIndicator) {
  Log.d(TAG, " Typing Started : " + typingIndicator.toString());
}

@Override
public void onTypingEnded(TypingIndicator typingIndicator) {
  Log.d(TAG, " Typing Ended : " + typingIndicator.toString());
}

});
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

TypingIndicator Payload Structure

The TypingIndicator object contains information about typing status:
ParameterTypeDescription
senderUserUser who is typing
receiverIdStringID of the receiver (user UID or group GUID)
receiverTypeStringType of receiver. Values: "user", "group"
metadataJSONObjectCustom typing metadata
lastTimestamplongUnix timestamp of last typing event
typingStatusStringTyping status. Values: "started", "ended"
Sample TypingIndicator Object:
{
  "sender": {
    "uid": "user_123",
    "name": "John Doe",
    "avatar": "https://example.com/avatar.png",
    "status": "online",
    "role": "default"
  },
  "receiverId": "user_456",
  "receiverType": "user",
  "metadata": {},
  "lastTimestamp": 1699900000,
  "typingStatus": "started"
}
The nested User object in sender contains:
ParameterTypeDescription
uidStringUnique identifier of the user
nameStringDisplay name of the user
avatarStringURL to user’s profile picture
linkStringURL to user’s profile page
roleStringUser role for access control
metadataJSONObjectCustom data set by developer
statusStringUser online status. Values: "online", "offline"
statusMessageStringCustom status message
lastActiveAtlongUnix timestamp of last activity
hasBlockedMebooleanWhether this user has blocked the logged-in user
blockedByMebooleanWhether the logged-in user has blocked this user
tagsArray<String>List of tags for user identification
deactivatedAtlongUnix timestamp when user was deactivated (0 if active)
Always remove message listeners when they’re no longer needed (e.g., in onDestroy() or when navigating away). Failing to remove listeners can cause memory leaks and duplicate event handling.

Next Steps

Delivery & Read Receipts

Track message delivery and read status

Receive Messages

Handle incoming messages with listeners

Retrieve Conversations

Fetch conversation list

Real-Time Listeners

Learn more about event listeners