> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Transient Messages

> Send and receive ephemeral real-time messages that are not stored on the server using the CometChat iOS SDK.

<Accordion title="AI Integration Quick Reference">
  ```swift theme={null}
  // Send transient message to user
  let data: [String: Any] = ["LIVE_REACTION": "heart"]
  let msg = TransientMessage(receiverID: "UID", receiverType: .user, data: data)
  CometChat.sendTransientMessage(message: msg)

  // Listen for transient messages (CometChatMessageDelegate)
  func onTransisentMessageReceived(_ message: TransientMessage) {
      print("Transient:", message.data)
  }
  ```
</Accordion>

## Key Characteristics

| Characteristic  | Description                      |
| --------------- | -------------------------------- |
| Fire-and-forget | No success/failure callbacks     |
| NOT persisted   | Cannot be retrieved from history |
| Real-time only  | Receiver must be online          |
| No receipts     | No delivery/read receipts        |

***

## Use Cases

| Use Case              | Description                            |
| --------------------- | -------------------------------------- |
| Live reactions        | Heart, thumbs up, emoji animations     |
| Live location         | Real-time location sharing             |
| Ephemeral indicators  | Temporary status updates               |
| Custom real-time data | Any data that doesn't need persistence |

***

## Send Transient Message (User)

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    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
    ```
  </Tab>

  <Tab title="Objective C">
    ```objc theme={null}
    NSDictionary *data = @{@"LIVE_REACTION": @"heart"};
    TransientMessage *transientMessage = [[TransientMessage alloc] initWithReceiverID:@"cometchat-uid-2" receiverType:ReceiverTypeUser data:data];
    [CometChat sendTransientMessageWithMessage:transientMessage];
    ```
  </Tab>
</Tabs>

***

## Send Transient Message (Group)

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    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)
    ```
  </Tab>
</Tabs>

***

## Send Live Reaction

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let data = ["LIVE_REACTION": "heart", "type": "live_reaction"]
    let transientMessage = TransientMessage(receiverID: "cometchat-uid-2", receiverType: .user, data: data)
    CometChat.sendTransientMessage(message: transientMessage)
    ```
  </Tab>
</Tabs>

### Common Live Reactions

| Reaction    | Value          |
| ----------- | -------------- |
| Heart       | `"heart"`      |
| Thumbs Up   | `"thumbsup"`   |
| Thumbs Down | `"thumbsdown"` |
| Laugh       | `"laugh"`      |
| Wow         | `"wow"`        |
| Sad         | `"sad"`        |
| Angry       | `"angry"`      |

***

## Send Live Location

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    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)
    ```
  </Tab>
</Tabs>

### Live Location Data Properties

| Property  | Type     | Description                 |
| --------- | -------- | --------------------------- |
| type      | `String` | `"live_location"`           |
| latitude  | `Double` | Latitude coordinate         |
| longitude | `Double` | Longitude coordinate        |
| accuracy  | `Double` | Location accuracy in meters |
| timestamp | `Double` | Unix timestamp              |

***

## Real-time Transient Message Events

To receive transient messages, implement `CometChatMessageDelegate`:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    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
    ```
  </Tab>

  <Tab title="Objective C">
    ```objc theme={null}
    - (void)onTransisentMessageReceived:(TransientMessage *)message {
        NSLog(@"TransientMessage received: %@", [message stringValue]);
    }
    ```
  </Tab>
</Tabs>

***

The received object is a [`TransientMessage`](/sdk/reference/auxiliary#transientmessage).

## TransientMessage Object Properties

| Property       | Type            | Description                         |
| -------------- | --------------- | ----------------------------------- |
| `sender`       | `User?`         | User who sent the transient message |
| `receiverID`   | `String`        | UID of user or GUID of group        |
| `receiverType` | `ReceiverType`  | `.user` or `.group`                 |
| `data`         | `[String: Any]` | Custom data dictionary              |

<Note>
  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.
</Note>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Typing Indicators" icon="keyboard" href="/sdk/ios/typing-indicators">
    Show real-time typing status in conversations
  </Card>

  <Card title="Send Messages" icon="paper-plane" href="/sdk/ios/send-message">
    Send text, media, and custom messages
  </Card>
</CardGroup>
