> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Integration

## Enable Push notifications

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/pPsJINHbgj20OYP-/images/80a520bb-pushnotification-enable-e64632d479a2ebba111453b95bd522c6.png?fit=max&auto=format&n=pPsJINHbgj20OYP-&q=85&s=368652c7f5479f420524e9fee2618a7a" width="1202" height="607" data-path="images/80a520bb-pushnotification-enable-e64632d479a2ebba111453b95bd522c6.png" />
</Frame>

1. Login to [CometChat](https://app.cometchat.com/login) dashboard and select your app.
2. Navigate to **Notifications** > **Notifications** in the left-hand menu.
3. Enable the Push notifications feature.
4. Continue to configure Push notifications by clicking on "Configure".

## Add Providers

Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNS) are the two primary supported providers for sending push notifications.

### Add FCM credentials

#### Pre-requisite

Generate a service account key for your Firebase application by navigating to the "Service accounts" section within the "Project settings" of the Firebase Cloud Messaging Dashboard. Generate new private key and download the JSON file. This will be required in the next steps.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/IdVhVuxpbq9MoHCr/images/c6447647-pushnotification-fcm-68092b02a5361d51ba14b09289da3a78.png?fit=max&auto=format&n=IdVhVuxpbq9MoHCr&q=85&s=f30cdd31ff08e5c157f7e0f3c990de63" width="1800" height="1201" data-path="images/c6447647-pushnotification-fcm-68092b02a5361d51ba14b09289da3a78.png" />
</Frame>

#### Add credentials

1. Select the "+ Add Credentials" button.
2. In the dialogue that appears, provide a unique, memorable identifier for your provider.
3. Upload the service account JSON file you previously acquired.
4. Specify whether the push payload should include the "notification" key. Additional information on this configuration is available in FCM's documentation - [About FCM messages](https://firebase.google.com/docs/cloud-messaging/concept-options).

Similarly, you can add multiple FCM Credentials in case you have multiple FCM projects for your apps.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/4Rjsfsajp8Hou6fe/images/a3989fec-add-fcm-credentials-f53b2450ec0d3d9b10b7884386e7bb2f.png?fit=max&auto=format&n=4Rjsfsajp8Hou6fe&q=85&s=ce6c4ef0957e38a7fd515ba31a245500" width="1800" height="1200" data-path="images/a3989fec-add-fcm-credentials-f53b2450ec0d3d9b10b7884386e7bb2f.png" />
</Frame>

### Add APNS credentials

#### Pre-requisite

1. To generate a .p8 key file, go to [Apple developer account](https://developer.apple.com/account), then select "Certificates, IDs & Profiles".
2. Select Keys and click on the "+" button to add a new key.
3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register".
4. Then proceed to download the key file by clicking Download.
5. Make note of the Key ID, Team ID and your Bundle ID. These are required in the next steps.

Additional information on this configuration is available in Apple's documentation - [Create a private key to access a service](https://developer.apple.com/help/account/manage-keys/create-a-private-key/)

#### Add credentials

1. Select the "+ Add Credentials" button.
2. Enable the toggle if your app is in the Production. For apps under development, the toggle has to be disabled.
3. In the dialogue that appears, provide a unique, memorable identifier for your provider.
4. Store the Key ID, Team ID, Bundle ID for your app.
5. Upload the .p8 file
6. Enable "Include content-available" if you want to receive background notifications. However, this is not recommended as the background notifications are throttled. Additional information is available in Apple's documentation - [Pushing background updates to your App](https://developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app)
7. Enable "Include mutable-content" if you want to modify the notification before it is displayed to the user. Additional information is available in Apple's documentation - [Modifying content on newly delivered notifications](https://developer.apple.com/documentation/usernotifications/modifying-content-in-newly-delivered-notifications)

Similarly, you can add multiple APNS Credentials in case you have multiple apps with different Bundle IDs.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/3QMNZCcb2owfiSq_/images/1133421a-add-apns-credentials-f8c2fd747ab4cf3905c6d13cf215b4c1.png?fit=max&auto=format&n=3QMNZCcb2owfiSq_&q=85&s=eab5b91113cadc0af3ac714580b6f2e2" width="1800" height="1200" data-path="images/1133421a-add-apns-credentials-f8c2fd747ab4cf3905c6d13cf215b4c1.png" />
</Frame>

### Add Custom provider credentials

Custom providers allow you to make use of providers apart from FCM and APNs. This is implemented using webhook URL which gets all the required details that can be used to trigger Push notifications.

#### Pre-requisite

1. Your webhook endpoint must be accessible over `HTTPS`. This is essential to ensure the security and integrity of data transmission.
2. This URL should be publicly accessible from the internet.
3. Ensure that your endpoint supports the `HTTP POST` method. Event payloads will be delivered via `HTTP POST` requests in `JSON` format.
4. Configure your endpoint to respond immediately to the CometChat server with a 200 OK response. The response should be sent within 2 seconds of receiving the request.
5. For security, it is recommended to set up Basic Authentication that is usually used for server-to-server calls. This requires you to configure a username and password. Whenever your webhook URL is triggered, the HTTP Header will contain:

```html theme={null}
Authorization: Basic <Base64-encoded-credentials>
```

6. Your frontend application should implement the logic to get the push token and register it to your backend when the user logs in and unregister the push token when the user logs out.
7. To enable multi-device logins, you can map the push tokens to the user's auth tokens. Where each new login makes use of a new auth token.

#### Add credentials

1. Click on the "+ Add Credentials" button.
2. Enable the provider.
3. Enter the publically accessible Webhook URL.
4. It is recommended to enable Basic Authentication.
5. Enter the username and password.
6. Save the credentials.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/9Bqq9LdtQuQJXKNL/images/0a295fd9-cometchat-push-notifications-custom-provider-09e553a8b0fe2badff1f6e4ea5783307.png?fit=max&auto=format&n=9Bqq9LdtQuQJXKNL&q=85&s=b97ba1db5cfbf3fb27a3d46955db78a3" width="1800" height="1200" data-path="images/0a295fd9-cometchat-push-notifications-custom-provider-09e553a8b0fe2badff1f6e4ea5783307.png" />
</Frame>

#### How does it work?

The Custom provider is triggered once for an event in one-on-one conversation. In case of notifying the members of a group, the custom provider is triggered once for each user present in that group.

For example, if there are 100 members in the group, your webhook will receive 100 HTTP requests. Once for each member of the group.

Below are the sample payloads for different events:

<Tabs>
  <Tab title="Chat notification payload">
    ```json theme={null}
    {
      "trigger": "push-notification-payload-generated",
      "data": {
        "to": {
          "uid": "cometchat-uid-2"
        },
        "notificationDetails": {
          // Notification details
          "title": "Andrew Joseph", // The title of the notification to be displayed
          "body": "Hello!", // The body of the notification to be displayed
      
          // Sender's details
          "sender": "cometchat-uid-1", // UID of the user who sent the message.
          "senderName": "Andrew Joseph", // Name of the user who sent the message.
          "senderAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", // Avatar URL of the user.
      
          // Receiver's details
          "receiver": "cometchat-uid-2", // UID or GUID of the receiver.
          "receiverName": "George Alan", // Name of the user or group.
          "receiverAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", // Avatar URL of the receiver.
          "receiverType": "user", // Values can be "user" or "group"
      
          // Message details
          "tag": "123", // The ID of the message that can be used as the ID of the notification to be displayed.
          "conversationId": "cometchat-uid-1_user_cometchat-uid-2", // The ID of the conversation that the message belongs to.
          "type": "chat",
          "sentAt": "1741847453000",
          "message": {CometChat Message Object}, // Present if "Include message object" is enabled. The message object is present for new messages or in case a message was edited or deleted.
          "custom": {Custom JSON} // Custom JSON object is added in case it is configured in the preferences.
        }
      },
      "appId": "app123",
      "region": "us/eu/in",
      "webhook": "custom"
    }
    ```
  </Tab>

  <Tab title="Call notification payload">
    ```json theme={null}
    {
      "trigger": "push-notification-payload-generated",
      "data": {
        "to": {
          "uid": "cometchat-uid-2"
        },
        "notificationDetails": {
          // Notification details
          "title": "Caller", // The title of the notification to be displayed
          "body": "AUDIO CALL", // "AUDIO CALL" or "VIDEO CALL"
      
          // Sender's details
          "sender": "cometchat-uid-1", // UID of the user who sent the message.
          "senderName": "Andrew Joseph", // Name of the user who sent the message.
          "senderAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", // Avatar URL of the user.
      
          // Receiver's details
          "receiver": "cometchat-uid-2", // UID or GUID of the receiver.
          "receiverName": "George Alan", // Name of the user or group.
          "receiverAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", // Avatar URL of the receiver.
          "receiverType": "user", //  "user" or "group"
      
          // Message details
          "tag": "123", // The ID of the message that can be used as the ID of the notification to be displayed.
          "conversationId": "cometchat-uid-1_user_cometchat-uid-2", // The ID of the conversation that the call belongs to.
          "type": "call",
      
          // Call details
          "callAction": "initiated", // "initiated" or "cancelled" or "unanswered" or "ongoing" or "rejected" or "ended" or "busy"
          "sessionId": "v1.123.aik2", // The unique sessionId of the call that can be used as an identifier in CallKit or ConnectionService.
          "callType": "audio", // "audio" or "video"
          "sentAt": "1741847453000",
          "custom": {Custom JSON} // Custom JSON object is added in case it is configured in the preferences.
        }
      },
      "appId": "app123",
      "region": "us/eu/in",
      "webhook": "custom"
    }
    ```
  </Tab>

  <Tab title="Reaction notification payload">
    ```json theme={null}
    {
      "trigger": "push-notification-payload-generated",
      "data": {
        "to": { 
          "uid": "cometchat-uid-2"
        },
        "notificationDetails": {
          // Notification details
          "title": "Andrew Joseph",
          "body": "Reacted to your message: 😎",
          
          // Sender's details
          "sender": "cometchat-uid-1",
          "senderName": "Andrew Joseph",
          "senderAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",

          // Receiver's details
          "receiver": "cometchat-uid-1",
          "receiverName": "Andrew Joseph",
          "receiverAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
          "receiverType": "user",

          // Message details
          "tag": "58",
          "conversationId": "cometchat-uid-1_user_cometchat-uid-2",
          "type": "chat",
          "sentAt": "1741847453000",
          "custom": {Custom JSON} // Custom JSON object is added in case it is configured in the preferences.
        }
      },
      "appId": "app123",
      "region": "us",
      "webhook": "custom"
    }
    ```
  </Tab>

  <Tab title="Group action notification payload">
    ```json theme={null}
    {
      "trigger": "push-notification-payload-generated",
      "data": {
        "to": {
          "uid": "g-messages-none"
        },
        "notificationDetails": {
          // Notification details
          "title": "Hiking group",
          "body": "Andrew Joseph has left", // Similarly for joined, kicked, banned, unbanned, added events
          
          // Sender details
          "sender": "cometchat-uid-1",
          "senderName": "Andrew Joseph",
          "senderAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
          
          // Receiver details
          "receiver": "cometchat-guid-1",
          "receiverName": "Hiking group",
          "receiverType": "group",
          
          // Message details
          "tag": "cometchat-guid-1",
          "conversationId": "group_cometchat-guid-1",
          "type": "chat",
          "sentAt": "1741847453000",
          "custom": {Custom JSON} // Custom JSON object is added in case it is configured in the preferences.
        }
      },
      "appId": "app123",
      "region": "us",
      "webhook": "custom"
    }
    ```
  </Tab>
</Tabs>

#### Sample server-side code

```typescript theme={null}
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.use(express.json());

// Optional: Basic authentication middleware
const basicAuth = (req, res, next) => {
  const authHeader = req.headers['authorization'];
  if (!authHeader || !authHeader.startsWith('Basic ')) {
    return res.status(401).json({ message: 'Unauthorized' });
  }
  next();
};

const triggerPushNotification = async (to, notificationDetails) => {
  const { name, uid } = to;
  const { type, notificationTitle, notificationBody } = notificationDetails;

  if (type == 'call') {
    console.log('Push notification for calling event');
    // Use the following details to send a call notification.
    const { callAction, sessionId, callType } = notificationDetails;
  }

  if (type == 'chat') {
    console.log('Push notification for messaging event');
  }

  const token = await fetchPushToken(uid);

  // Your implementation for sending the Push notification
  await sendPushNotification(token, notificationTitle, notificationBody);
};

app.post('/webhook', basicAuth, (req, res) => {
  const { trigger, data, appId, region, webhook } = req.body;

  if (
    trigger !== 'push-notification-payload-generated' ||
    webhook !== 'custom'
  ) {
    return res.status(400).json({ message: 'Invalid trigger or webhook type' });
  }

  console.log('Received Webhook:', JSON.stringify(req.body, null, 2));

  triggerPushNotification(to, data)
    .then((result) => {
      console.log(
        'Successfully triggered Push notification for',
        appId,
        to.uid,
        result
      );
    })
    .catch((error) => {
      console.error(
        'Something went wrong while triggering Push notification for',
        appId,
        to.uid,
        error.message
      );
    });

  res.status(200).json({ message: 'Webhook received successfully' });
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});
```

## Tokens management

### Register push token after login

Push tokens, obtained from the APIs or SDKs provided by the platforms or frameworks in use, must be registered on behalf of the logged in user with the CometChat backend. For this purpose, CometChat SDKs v4+ offer the following functions:

Push token registration should be completed in two scenarios:

1. Following the success of `CometChat.login()` & receiving user's permission to receiver Push notifications.
2. When a refresh token becomes available.

To register a token, use the `CometChatNotifications.registerPushToken()` method from the SDK. This method accepts the following parameters.

| Parameter    | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pushToken`  | String | The `pushToken` can contain:<br /><br />• Firebase (FCM) token<br />• Device token (iOS only)<br />• VoIP token (iOS only)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `platform`   | String | The `platform` can take the following values:<br /><br />• PushPlatforms.FCM\_ANDROID<br />• PushPlatforms.FCM\_FLUTTER\_ANDROID<br />• PushPlatforms.FCM\_FLUTTER\_iOS<br />• PushPlatforms.APNS\_FLUTTER\_DEVICE<br />• PushPlatforms.APNS\_FLUTTER\_VOIP<br />• PushPlatforms.FCM\_iOS<br />• PushPlatforms.APNS\_iOS\_DEVICE<br />• PushPlatforms.APNS\_iOS\_VOIP<br />• PushPlatforms.FCM\_WEB<br />• PushPlatforms.FCM\_REACT\_NATIVE\_ANDROID<br />• PushPlatforms.FCM\_REACT\_NATIVE\_iOS<br />• PushPlatforms.APNS\_REACT\_NATIVE\_DEVICE<br />• PushPlatforms.APNS\_REACT\_NATIVE\_VOIP<br />• PushPlatforms.FCM\_IONIC\_CORDOVA\_ANDROID<br />• PushPlatforms.FCM\_IONIC\_CORDOVA\_iOS<br />• PushPlatforms.APNS\_IONIC\_CORDOVA\_DEVICE<br />• PushPlatforms.APNS\_IONIC\_CORDOVA\_VOIP |
| `providerId` | String | The `providerId` should match with:<br /><br />• Any one of the FCM provider identifiers in case of an FCM token.<br />• Any one of the APNS provider identifiers in case of Device or VoIP tokens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

<Tabs>
  <Tab title="JavaScript">
    ```js theme={null}
    // This is applicable for web, React native, Ionic cordova

    // CometChat.init() success.
    // CometChat.login() success.
    // User has granted permission to display push notifications.

    // For web
    CometChatNotifications.registerPushToken(
      pushToken,
      CometChatNotifications.PushPlatforms.FCM_WEB,
      "fcm-provider-2"
    )
      .then((payload) => {
        console.log("Token registration successful");
      })
      .catch((err) => {
        console.log("Token registration failed:", err);
      });

    // For React Native Android
    CometChatNotifications.registerPushToken(
      pushToken,
      CometChatNotifications.PushPlatforms.FCM_REACT_NATIVE_ANDROID,
      "fcm-provider-2"
    )
      .then((payload) => {
        console.log("Token registration successful");
      })
      .catch((err) => {
        console.log("Token registration failed:", err);
      });

    // For React Native iOS
    CometChatNotifications.registerPushToken(
      pushToken,
      CometChatNotifications.PushPlatforms.FCM_REACT_NATIVE_iOS,
      "fcm-provider-2"
    )
      .then((payload) => {
        console.log("Token registration successful");
      })
      .catch((err) => {
        console.log("Token registration failed:", err);
      });

    // For Ionic cordova Android
    CometChatNotifications.registerPushToken(
      pushToken,
      CometChatNotifications.PushPlatforms.FCM_IONIC_CORDOVA_ANDROID,
      "fcm-provider-2"
    )
      .then((payload) => {
        console.log("Token registration successful");
      })
      .catch((err) => {
        console.log("Token registration failed:", err);
      });

    // For Ionic cordova iOS
    CometChatNotifications.registerPushToken(
      pushToken,
      CometChatNotifications.PushPlatforms.FCM_IONIC_CORDOVA_iOS,
      "fcm-provider-2"
    )
      .then((payload) => {
        console.log("Token registration successful");
      })
      .catch((err) => {
        console.log("Token registration failed:", err);
      });

    // Similary, use this method to register refresh token.
    ```
  </Tab>

  <Tab title="Android">
    ```kotlin theme={null}
    // CometChat.init() success.
    // CometChat.login() success.
    // User has granted permission to display push notifications.
    CometChatNotifications.registerPushToken(pushToken, PushPlatforms.FCM_ANDROID, "fcm-provider-2", new CometChat.CallbackListener<String>() {
        @Override
        public void onSuccess(String s) {
            Log.e(TAG, "onSuccess:  CometChat Notification Registered : "+s );
            listener.onSuccess(s);
        }

        @Override
        public void onError(CometChatException e) {
            Log.e(TAG, "onError: Notification Registration Failed : "+e.getMessage());
            listener.onError(e);
        }
    });

    // Similary, use this method to register refresh token.
    ```
  </Tab>

  <Tab title="iOS">
    ```swift theme={null}
    // CometChat.init() success.
    // CometChat.login() success.
    // User has granted permission to display push notifications.
    CometChatNotifications.registerPushToken(pushToken: pushToken, platform: CometChatNotifications.PushPlatforms.FCM_iOS, providerId: "apns-provider-2", onSuccess: { (success) in
      print("registerPushToken: \(success)")
    }) { (error) in
      print("registerPushToken: \(error.errorCode) \(error.errorDescription)")
    }

    // Similary, use this method to register refresh token.
    ```
  </Tab>

  <Tab title="Flutter">
    ```dart theme={null}
    // CometChat.init() success.
    // CometChat.login() success.
    // User has granted permission to display push notifications.

    // For Android (FCM)
    CometChatNotifications.registerPushToken(
      PushPlatforms.FCM_FLUTTER_ANDROID,
      providerId: "fcm-provider-1",
      fcmToken: token,
      onSuccess: (response) {
        debugPrint("registerPushToken:success ${response.toString()}");
      },
      onError: (e) {
        debugPrint("registerPushToken:error ${e.toString()}");
      },
    );

    // For iOS (FCM)
    CometChatNotifications.registerPushToken(
      PushPlatforms.FCM_FLUTTER_iOS,
      providerId: "fcm-provider-1",
      fcmToken: token,
      onSuccess: (response) {
        debugPrint("registerPushToken:success ${response.toString()}");
      },
      onError: (e) {
        debugPrint("registerPushToken:error ${e.toString()}");
      },
    );

    // For ios (APNS Device token)
    CometChatNotifications.registerPushToken(
      PushPlatforms.APNS_FLUTTER_DEVICE,
      providerId: "apns-provider-1",
      deviceToken: token,
      onSuccess: (response) {
        debugPrint("registerPushToken:success ${response.toString()}");
      },
      onError: (e) {
        debugPrint("registerPushToken:error ${e.toString()}");
      },
    );

    // For ios (APNS VoIP token)
    CometChatNotifications.registerPushToken(
      PushPlatforms.APNS_FLUTTER_VOIP,
      providerId: "apns-provider-1",
      voipToken: token,
      onSuccess: (response) {
        debugPrint("registerPushToken:success ${response.toString()}");
      },
      onError: (e) {
        debugPrint("registerPushToken:error ${e.toString()}");
      },
    );

    // Similary, use this method to register refresh token.
    ```
  </Tab>
</Tabs>

### Unregister push token before logout

Typically, push token unregistration should occur prior to user logout, using the `CometChat.logout()` method.

For token unregistration, use the `CometChatNotifications.unregisterPushToken()` method provided by the SDKs.

<Tabs>
  <Tab title="JavaScript">
    ```js theme={null}
    // This is applicable for web, React native, Ionic cordova
    await CometChatNotifications.unregisterPushToken();

    // Followed by CometChat.logout();
    ```
  </Tab>

  <Tab title="Android">
    ```kotlin theme={null}
    CometChatNotifications.unregisterPushToken(new CometChat.CallbackListener<String>() {
        @Override
        public void onSuccess(String s) {
            // Success callback
        }

        @Override
        public void onError(CometChatException e) {
            // Error callback
        }
    });

    // Followed by CometChat.logout();
    ```
  </Tab>

  <Tab title="iOS">
    ```swift theme={null}
    CometChatNotifications.unregisterPushToken { success in
        print("unregisterPushToken: \(success)")
    } onError: { error in
        print("unregisterPushToken: \(error.errorCode) \(error.errorDescription)")
    }

    // Followed by CometChat.logout();
    ```
  </Tab>

  <Tab title="Flutter">
    ```dart theme={null}
    CometChatNotifications.unregisterPushToken(onSuccess: (response) {
      debugPrint("unregisterPushToken:success ${response.toString()}");
    }, onError: (e) {
      debugPrint("unregisterPushToken:error ${e.toString()}");
    });
    ```
  </Tab>
</Tabs>

## Handle incoming Push notifications

Push notifications should be managed primarily when the app is in the background or in a terminated state.

For web and mobile applications, the Firebase Cloud Messaging (FCM) SDK offers handler functions to receive Push Notifications.

For iOS applications, the FCM SDK can be used as described previously, or alternatively, PushKit can be implemented for better integration and management of chat and call (VoIP) notifications.

The push payload delivered to the user's device includes the following information, which can be customized to suit the desired notification style:

<Tabs>
  <Tab title="Details available in the payload">
    ```json theme={null}
    {
      // Notification details
      "title": "Andrew Joseph", // The title of the notification to be displayed
      "body": "Hello!", // The body of the notification to be displayed

      // Sender's details
      "sender": "cometchat-uid-1", // UID of the user who sent the said message.
      "senderName": "Andrew Joseph", // Name of the user who sent the said message.
      "senderAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", // Avatar URL of the user.

      // Receiver's details
      "receiver": "cometchat-uid-2", // UID or GUID of the receiver.
      "receiverName": "George Alan", // Name of the user or group.
      "receiverAvatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", // Avatar URL of the receiver.
      "receiverType": "user", // Values can be "user" or "group"

      // Message details
      "tag": "123", // The ID of the said message that can be used as the ID of the notification to be displayed.
      "conversationId": "cometchat-uid-1_user_cometchat-uid-2", // The ID of the conversation that the said message belongs to.
      "type": "chat", // Values can be "call" or "chat". If this is "call", the below details will be available.

      // Call details
      "callAction": "initiated", // Values can be "initiated" or "cancelled" or "unanswered" or "ongoing" or "rejected" or "ended" or "busy"
      "sessionId": "v1.123.aik2", // The unique sessionId of the said call that can be used as unique identifier in CallKit or ConnectionService.
      "callType": "audio", // Values can be "audio" or "video"
      "sentAt": "1741847453000",
      "message": {CometChat Message Object}, // Present if "Include message object" is enabled. The message object is present for new messages or in case a message was edited or deleted.
      "custom": {Custom JSON} // Custom JSON object is added in case it is configured in the preferences.
    }
    ```
  </Tab>
</Tabs>

## Sample apps

Check out our sample apps for understanding the implementation.

<CardGroup>
  <Card title="React - Push notifications sample app" icon="github" href="https://github.com/cometchat/cometchat-push-notification-app-react">
    Push notifications sample app for the web

    View on Github
  </Card>

  <Card title="React Native - Push notifications sample app" icon="github" href="https://github.com/cometchat/cometchat-push-notification-app-react-native">
    Push notifications sample app for React Native

    View on Github
  </Card>

  <Card title="iOS - Push notifications sample app" icon="github" href="https://github.com/cometchat/cometchat-push-notification-app-ios">
    Push notifications sample app for iOS

    View on Github
  </Card>

  <Card title="Android - Push notifications sample app" icon="github" href="https://github.com/cometchat/cometchat-push-notification-app-android">
    Push notifications sample app for Android

    View on Github
  </Card>

  <Card title="Flutter - Push notifications sample app" icon="github" href="https://github.com/cometchat/cometchat-push-notification-app-flutter">
    Push notifications sample app for Flutter

    View on Github
  </Card>
</CardGroup>
