Skip to main content
Quick Reference for AI Agents & Developers
  • Send transient: CometChat.sendTransientMessage(message:) — pass TransientMessage(receiverID:receiverType:data:)
  • Receive transient: onTransientMessageReceived(_:) in message listener delegate
  • Note: Transient messages are NOT saved — receiver must be online
  • Use cases: Live location sharing, real-time indicators, ephemeral data
  • Related: Send Message · Typing Indicators · Messaging Overview

Key Characteristics

CharacteristicDescription
Fire-and-forgetNo success/failure callbacks
NOT persistedCannot be retrieved from history
Real-time onlyReceiver must be online
No receiptsNo delivery/read receipts

Use Cases

Use CaseDescription
Live reactionsHeart, thumbs up, emoji animations
Live locationReal-time location sharing
Ephemeral indicatorsTemporary status updates
Custom real-time dataAny data that doesn’t need persistence

Send Transient Message (User)

let data: [String: Any] = ["LIVE_REACTION": "heart", "timestamp": Date().timeIntervalSince1970]
let transientMessage = TransientMessage(receiverID: "cometchat-uid-2", receiverType: .user, data: data)
CometChat.sendTransientMessage(message: transientMessage)

// Note: Fire-and-forget - no success/failure callback
// Message is NOT persisted - receiver must be online
Method: CometChat.sendTransientMessage(message:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user
data[String: Any]["LIVE_REACTION": "heart", "timestamp": 1772028567.875231]

Send Transient Message (Group)

let data: [String: Any] = ["LIVE_REACTION": "thumbsup", "timestamp": Date().timeIntervalSince1970]
let transientMessage = TransientMessage(receiverID: "cometchat-guid-1", receiverType: .group, data: data)
CometChat.sendTransientMessage(message: transientMessage)
Method: CometChat.sendTransientMessage(message:)
ParameterTypeValue
receiverIDString"cometchat-guid-1"
receiverTypeCometChat.ReceiverType.group
data[String: Any]["LIVE_REACTION": "thumbsup", "timestamp": 1772028570.0602489]

Send Live Reaction

let data = ["LIVE_REACTION": "heart", "type": "live_reaction"]
let transientMessage = TransientMessage(receiverID: "cometchat-uid-2", receiverType: .user, data: data)
CometChat.sendTransientMessage(message: transientMessage)
Method: CometChat.sendTransientMessage(message:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user
data.LIVE_REACTIONString"heart"
data.typeString"live_reaction"

Common Live Reactions

ReactionValue
Heart"heart"
Thumbs Up"thumbsup"
Thumbs Down"thumbsdown"
Laugh"laugh"
Wow"wow"
Sad"sad"
Angry"angry"

Send Live Location

let data: [String: Any] = [
    "type": "live_location",
    "latitude": 37.7749,
    "longitude": -122.4194,
    "accuracy": 10.0,
    "timestamp": Date().timeIntervalSince1970
]
let transientMessage = TransientMessage(receiverID: "cometchat-uid-2", receiverType: .user, data: data)
CometChat.sendTransientMessage(message: transientMessage)
Method: CometChat.sendTransientMessage(message:)
ParameterTypeValue
receiverIDString"cometchat-uid-2"
receiverTypeCometChat.ReceiverType.user
data.typeString"live_location"
data.latitudeDouble37.7749
data.longitudeDouble-122.4194
data.accuracyDouble10.0
data.timestampDouble1772028575.777206

Live Location Data Properties

PropertyTypeDescription
typeString"live_location"
latitudeDoubleLatitude coordinate
longitudeDoubleLongitude coordinate
accuracyDoubleLocation accuracy in meters
timestampDoubleUnix timestamp

Real-time Transient Message Events

To receive transient messages, implement CometChatMessageDelegate:
extension YourViewController: CometChatMessageDelegate {
    
    func onTransisentMessageReceived(_ message: TransientMessage) {
        print("Transient message received")
        print("Sender UID: \(message.sender?.uid ?? "")")
        print("Sender Name: \(message.sender?.name ?? "")")
        print("Receiver ID: \(message.receiverID)")
        print("Receiver Type: \(message.receiverType)")
        print("Data: \(message.data)")
        
        // Handle specific data types
        if let reaction = message.data["LIVE_REACTION"] as? String {
            print("Live Reaction: \(reaction)")
            // Show reaction animation
        }
        
        if let type = message.data["type"] as? String, type == "live_location" {
            let lat = message.data["latitude"] as? Double ?? 0
            let lon = message.data["longitude"] as? Double ?? 0
            print("Live Location: \(lat), \(lon)")
            // Update map marker
        }
    }
}

// Register the delegate:
CometChat.messagedelegate = self
Method: onTransisentMessageReceived(_ message: TransientMessage)TransientMessage Object:
ParameterTypeValue
sender.uidString"cometchat-uid-1"
sender.nameString"John Doe"
receiverIDString"cometchat-uid-2"
receiverTypeReceiverType.user
data[String: Any]["LIVE_REACTION": "heart"]

TransientMessage Object Properties

PropertyTypeDescription
senderUser?User who sent the transient message
receiverIDStringUID of user or GUID of group
receiverTypeReceiverType.user or .group
data[String: Any]Custom data dictionary
Transient messages are NOT persisted and cannot be retrieved later. The receiver must be online to receive them. There are no delivery/read receipts for transient messages.