Skip to main content
Quick Reference for AI Agents & Developers
  • Start typing: CometChat.startTyping(indicator:) — pass TypingIndicator(receiverID:receiverType:)
  • End typing: CometChat.endTyping(indicator:)
  • Listen for typing: onTypingStarted(_:), onTypingEnded(_:) in message listener delegate
  • Receiver types: .user, .group
  • Related: Send Message · Receive Message · Messaging Overview

Key Characteristics

CharacteristicDescription
Fire-and-forgetNo success/failure callbacks
TransientNot persisted, receiver must be online
Real-time onlyNo history or missed events
Supports metadataCan send custom data with indicator

Send a Typing Indicator

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

Start Typing (User)

let typingIndicator = TypingIndicator(receiverID: "cometchat-uid-2", receiverType: .user)
CometChat.startTyping(indicator: typingIndicator)
Method: CometChat.startTyping(indicator:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user
metadata[String: Any]?nil

Start Typing (Group)

let typingIndicator = TypingIndicator(receiverID: "group-guid-1", receiverType: .group)
CometChat.startTyping(indicator: typingIndicator)
Method: CometChat.startTyping(indicator:)
ParameterTypeValue
receiverIDString"group-guid-1"
receiverTypeCometChat.ReceiverType.group
metadata[String: Any]?nil

Start Typing with Metadata

let typingIndicator = TypingIndicator(receiverID: "cometchat-uid-2", receiverType: .user)
typingIndicator.metadata = ["isVoiceTyping": true, "language": "en"]
CometChat.startTyping(indicator: typingIndicator)
Method: CometChat.startTyping(indicator:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user
metadata[String: Any]["isVoiceTyping": true, "language": "en"]
You can use the metadata field of the TypingIndicator class to pass additional data along with the typing indicators. This data will be received at the receiver end and can be obtained using the metadata property.

End Typing (User)

let typingIndicator = TypingIndicator(receiverID: "cometchat-uid-2", receiverType: .user)
CometChat.endTyping(indicator: typingIndicator)
Method: CometChat.endTyping(indicator:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user

End Typing (Group)

let typingIndicator = TypingIndicator(receiverID: "group-guid-1", receiverType: .group)
CometChat.endTyping(indicator: typingIndicator)
Method: CometChat.endTyping(indicator:)
ParameterTypeValue
receiverIDString"group-guid-1"
receiverTypeCometChat.ReceiverType.group

Real-time Typing Indicators

In other words, as a recipient, how do I know when someone is typing? To receive typing indicators, implement CometChatMessageDelegate:
extension YourViewController: CometChatMessageDelegate {
    
    func onTypingStarted(_ typingDetails: TypingIndicator) {
        print("User started typing")
        print("Sender UID: \(typingDetails.sender?.uid ?? "")")
        print("Sender Name: \(typingDetails.sender?.name ?? "")")
        print("Receiver ID: \(typingDetails.receiverID)")
        print("Receiver Type: \(typingDetails.receiverType)")
        print("Metadata: \(typingDetails.metadata ?? [:])")
    }
    
    func onTypingEnded(_ typingDetails: TypingIndicator) {
        print("User stopped typing")
        print("Sender: \(typingDetails.sender?.name ?? "")")
    }
}

// Register the delegate:
CometChat.messagedelegate = self
Method: onTypingStarted(_ typingDetails: TypingIndicator)TypingIndicator Object:
ParameterTypeValue
sender.uidString"cometchat-uid-1"
sender.nameString"John Doe"
sender.avatarString"https://example.com/avatar.png"
receiverIDString"cometchat-uid-2"
receiverTypeReceiverType.user
metadata[String: Any]?nil
Method: onTypingEnded(_ typingDetails: TypingIndicator)TypingIndicator Object:
ParameterTypeValue
sender.uidString"cometchat-uid-1"
sender.nameString"John Doe"
receiverIDString"cometchat-uid-2"
receiverTypeReceiverType.user

TypingIndicator Object Properties

PropertyTypeDescription
senderUser?User object of the person typing
receiverIDStringUID of user or GUID of group
receiverTypeReceiverType.user or .group
metadata[String: Any]?Custom data sent with indicator

Receiver Types

TypeValueDescription
User.userOne-on-one conversation
Group.groupGroup conversation

Delegate Methods

MethodDescription
onTypingStarted(_:)Called when user starts typing
onTypingEnded(_:)Called when user stops typing
Typing indicators are transient and not persisted. The receiver must be online to receive them.