> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-skills-v5-temp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Transient Messages

> Send and receive ephemeral real-time messages with the CometChat Flutter SDK for live reactions and temporary indicators.

<Accordion title="AI Integration Quick Reference">
  | Field              | Value                                                                                                                                                                                   |
  | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | Package            | `cometchat_sdk`                                                                                                                                                                         |
  | Import             | `import 'package:cometchat_sdk/cometchat_sdk.dart';`                                                                                                                                    |
  | Purpose            | Send and receive ephemeral real-time messages with the CometChat Flutter SDK for live reactions and temporary indicators.                                                               |
  | Key methods        | `addMessageListener()` · `sendTransientMessage()`                                                                                                                                       |
  | Key classes        | `TransientMessage` · `CometChatException` · `CometChatReceiverType`                                                                                                                     |
  | Listener callbacks | `onTransientMessageReceived()`                                                                                                                                                          |
  | Prerequisites      | SDK initialised via [`CometChat.init()`](/sdk/flutter/setup) and a logged-in user via [`CometChat.login()`](/sdk/flutter/authentication-overview).                                      |
  | Constraints        | `onSuccess` and `onError` are **both required** — omitting either is a compile error, and awaiting the call alone gives you nothing to act on. Put the success path inside `onSuccess`. |
  | Related            | [Send A Message](/sdk/flutter/send-message) · [Typing Indicators](/sdk/flutter/typing-indicators)                                                                                       |
  | Full reference     | [`TransientMessage`](/sdk/reference/auxiliary#transientmessage) · [`CometChatException`](/sdk/reference/auxiliary#cometchatexception)                                                   |
</Accordion>

Transient messages are messages that are sent in real-time only and are not saved or tracked anywhere. The receiver of the message will only receive the message if he is online and these messages cannot be retrieved later.

## Send a Transient Message

You can use the `sendTransientMessage()` method to send a transient message to a user or in a group. The receiver will receive this information in the `onTransientMessageReceived()` method of the `MessageListener` class. In order to send the transient message, you need to use the `TransientMessage` class.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    String receiverId = "cometchat-uid-2";
    Map<String,String> data= {};
    data["LIVE_REACTION"] =  "heart";
                        
    TransientMessage transientMessage = TransientMessage( receiverId:receiverId , receiverType:  CometChatReceiverType.user , data: data, );

    CometChat.sendTransientMessage(transientMessage, onSuccess: (){
     				debugPrint("Transient Message Sent");
      			}, onError: (CometChatException e){
    			debugPrint("Transient message sending failed with exception: ${e.message}");
    });
    ```
  </Tab>
</Tabs>

## Real-time Transient Messages

*In other words, as a recipient, how do I know when someone sends a transient message?*

You will receive the transient message in the `onTransientMessageReceived()` method of the registered `MessageListener` class.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    class Class_Name  with MessageListener {

    //CometChat.addMessageListener("listenerId", this);
    @override
    void onTransientMessageReceived(TransientMessage message) {
      // TODO: implement onTransientMessageReceived
    }


    }
    ```
  </Tab>
</Tabs>

The `TransientMessage` class consists of the below parameters:

| Parameter        | Information                                                                                               |
| ---------------- | --------------------------------------------------------------------------------------------------------- |
| **sender**       | An object of the User class holding all the information. related to the sender of the transient message.  |
| **receiverId**   | Unique Id of the receiver. This can be the Id of the group or the user the transient message is sent to.  |
| **receiverType** | The type of the receiver - `CometChatReceiverType.user` (user) or `CometChatReceiverType.``group `(group) |
| **data**         | A Map to provide data.                                                                                    |
