Skip to main content

Preferences, Templates & Sounds

Pre-requisite

To successfully integrate notifications in your app for any particular platform, you need to make sure you are using the appropriate version of the CometChat SDK that supports notifications.

  1. Android SDK version 4.0.9 and above
  2. iOS SDK version 4.0.51 and above
  3. Web SDK version 4.0.8 and above
  4. React Native SDK version 4.0.10 and above
  5. Ionic Cordova SDK version 4.0.8 and above
  6. Flutter SDK version 4.0.15 and above

Common Preferences

Set event preferences at the CometChat app-level and decide if users have the capability to override these settings. When "Override" toggle is enabled, users will have the capability to modify the default value that has been set.

Group preferences

Dashboard configuration

As the name suggests, these preferences help you to configure Notifications for events generated in group conversations.

CategoriesEventsAvailable preferencesCan user override?
ConversationsNew messages
  • Don't notify
  • Notify for all messages (Default)
  • Notify for messages with mentions
  • Yes (Default)
  • No
New replies
  • Don't notify
  • Notify for all replies (Default)
  • Notify for replies with mentions
  • Yes (Default)
  • No
Message actionsMessage is edited
  • Notify (Default) Push Notifications are automatically triggered for the edit event in order to retract the notification displaying the original message prior to its modification.
  • Yes
  • No (Default)
Message is deleted
  • Notify (Default) Push notifications are automatically triggered for the delete event in order to retract the notification displaying the original message.
  • Yes
  • No (Default)
Message receives a reaction
  • Don't notify
  • Notify for reactions received on all messages
  • Notify for reactions received on own messages (Default)
  • Yes (Default)
  • No
Group actionsA member leaves
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A new member is added
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A new member joins
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A member is kicked
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A member is banned
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A member is unbanned
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No
A member's scope changes
  • Don't notify (Default)
  • Notify
  • Yes (Default)
  • No

Client-side implementation

Fetch group preferences

CometChatNotifications.fetchPreferences() method retrieves the notification preferences as an instance of NotificationPreferences class. If the user has not configured any preferences, the default preferences defined by the CometChat administrator via the dashboard will be returned.

// This is applicable for web, React native, Ionic cordova
const preferences = await CometChatNotifications.fetchPreferences();

// Display Group preferences
const groupPreferences = preferences.getGroupPreferences();

const groupMessagesPreference = groupPreferences.getMessagesPreference();
const groupRepliesPreference = groupPreferences.getRepliesPreference();
const groupReactionsPreference = groupPreferences.getReactionsPreference();
const memberLeftPreference = groupPreferences.getMemberLeftPreference();
const memberAddedPreference = groupPreferences.getMemberAddedPreference();
const memberJoinedPreference = groupPreferences.getMemberJoinedPreference();
const memberKickedPreference = groupPreferences.getMemberKickedPreference();
const memberBannedPreference = groupPreferences.getMemberBannedPreference();
const memberUnbannedPreference = groupPreferences.getMemberUnbannedPreference();
const memberScopeChangedPreference = groupPreferences.getMemberScopeChangedPreference();

Update group preferences

CometChatNotifications.updatePreferences() method is used to update a user's notification preferences. The "override" toggle defined in the dashboard is crucial when updating preferences. If any preference is non-overridable, the method doesn't generate an error; it instead returns the NotificationPreferences object with the updated values where overrides are allowed.

This functionality can be beneficial for temporarily superseding certain user preferences to ensure notifications for a specific event are delivered. Nonetheless, it is advisable to use this approach temporarily to avoid confusing users with unexpected changes to their notification settings.

It is unnecessary to specify all values; only set and save the preferences that have been changed.

info

Since the user is performing this action, enums have values as SUBSCRIBE or DONT_SUBSCRIBE. It is equivalent to "Notify" and "Don't notify" respectively, from the dashboard preferences.

// This is applicable for web, React native, Ionic cordova
// The example demonstrates modifying all values; however, modifying only the changed values is sufficient.

// Instantiate the NotificationPreferences.
const updatedPreferences = new NotificationPreferences();

// Instantiate the preferences that you want to update.
const groupPreferences = new GroupPreferences();

// Change group preferences
groupPreferences.setMessagesPreference(MessagesOptions.DONT_SUBSCRIBE);
groupPreferences.setRepliesPreference(RepliesOptions.DONT_SUBSCRIBE);
groupPreferences.setReactionsPreference(ReactionsOptions.DONT_SUBSCRIBE);
groupPreferences.setMemberAddedPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberKickedPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberJoinedPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberLeftPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberBannedPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberUnbannedPreference(MemberActionsOptions.SUBSCRIBE);
groupPreferences.setMemberScopeChangedPreference(MemberActionsOptions.SUBSCRIBE);

// Load the updates in the NotificationPreferences instance.
updatedPreferences.setGroupPreferences(groupPreferences);

// Update the preferences and receive the udpated copy.
const preferences = await CometChatNotifications.updatePreferences(updatedPreferences);

One-on-one preferences

Dashboard configuration

As the name suggests, these preferences help you to configure Notifications for events generated in one-on-one conversations.

CategoriesEventsAvailable preferencesCan user override?
ConversationsNew messages
  • Don't notify
  • Notify for all messages (Default)
  • Notify for messages with mentions
  • Yes (Default)
  • No
New replies
  • Don't notify
  • Notify for all replies (Default)
  • Notify for replies with mentions
  • Yes (Default)
  • No
Message actionsMessage is edited
  • Notify (Default) Push notifications are automatically triggered for the edit event in order to retract the notification displaying the original message prior to its modification.
  • Yes
  • No (Default)
Message is deleted
  • Notify (Default) Push notifications are automatically triggered for the delete event in order to retract the notification displaying the original message.
  • Yes
  • No (Default)
Message receives a reaction
  • Don't notify
  • Notify for reactions received on all messages
  • Notify for reactions received on own messages (Default)
  • Yes (Default)
  • No

Client-side implementation

CometChatNotifications.fetchPreferences() method retrieves the notification preferences saved by the user as an instance of NotificationPreferences class. If the user has not configured any preferences, the default preferences defined by the CometChat administrator via the dashboard will be returned.

Fetch one-on-one preferences

// This is applicable for web, React native, Ionic cordova
const preferences = await CometChatNotifications.fetchPreferences();

// Display One-on-One preferences
const oneOnOnePreferences = preferences.getOneOnOnePreferences();

const oneOnOneMessagesPreference = oneOnOnePreferences.getMessagesPreference();
const oneOnOneRepliesPreference = oneOnOnePreferences.getRepliesPreference();
const oneOnOneReactionsPreference = oneOnOnePreferences.getReactionsPreference();

Update one-on-one preferences

CometChatNotifications.updatePreferences() method is used to update a user's notification preferences. The "override" toggle defined in the dashboard is crucial when updating preferences. If any preference is non-overridable, the method doesn't generate an error; it instead returns the NotificationPreferences object with the updated values where overrides are allowed.

This functionality can be beneficial for temporarily superseding certain user preferences to ensure notifications for a specific event are delivered. Nonetheless, it is advisable to use this approach temporarily to avoid confusing users with unexpected changes to their notification settings.

It is unnecessary to specify all values; only set and save the preferences that have been changed.

// This is applicable for web, React native, Ionic cordova
// The example demonstrates modifying all values; however, modifying only the changed values is sufficient.

// Instantiate the NotificationPreferences.
const updatedPreferences = new NotificationPreferences();

// Instantiate the preferences that you want to update.
const oneOnOnePreferences = new OneOnOnePreferences();

// Change one-on-one preferences
oneOnOnePreferences.setMessagesPreference(MessagesOptions.DONT_SUBSCRIBE);
oneOnOnePreferences.setRepliesPreference(RepliesOptions.DONT_SUBSCRIBE);
oneOnOnePreferences.setReactionsPreference(ReactionsOptions.DONT_SUBSCRIBE);

// Load the updates in the NotificationPreferences instance.
updatedPreferences.setOneOnOnePreferences(oneOnOnePreferences);

// Update the preferences and receive the udpated copy.
const preferences = await CometChatNotifications.updatePreferences(updatedPreferences);

Mute preferences

Dashboard configuration

These preferences allow you to control whether the users will be able to modify mute preferences.

Mute preferencesCan user configure?
Mute all notifications (DND)
  • Yes (Default) - Users can activate the Do Not Disturb (DND) feature.
  • No
Mute group conversations
  • Yes (Default) - Users can mute notifications for chosen group conversations for a specified duration.
  • No
Mute one-on-one conversations
  • Yes (Default) - Users can mute notifications for chosen one-on-one conversations for a specified duration.
  • No

Client-side implementation

Fetch mute preferences

CometChatNotifications.fetchPreferences() method retrieves the notification preferences saved by the user as an instance of NotificationPreferences class. If the user has not configured any preferences, the default preferences defined by the CometChat administrator via the dashboard will be utilized.

You can use the CometChatNotifications.getMutedConversations() method to display a list of conversations that have been muted by users. The method will return an array of MutedConversations object.

// This is applicable for web, React native, Ionic cordova
// Fetch mute preferences
const preferences = await CometChatNotifications.fetchPreferences();

// Display Mute preferences
const mutePreferences = preferences.getMutePreferences();
const DNDPreference = mutePreferences.getDNDPreference();

// Fetch muted conversations
const mutedConversations = await CometChatNotifications.getMutedConversations();

Update mute preferences

CometChatNotifications.updatePreferences() method is used to update a user's notification preferences. The "override" toggle defined in the dashboard is crucial when updating preferences. If any preference is non-overridable, the method doesn't generate an error; it instead returns the NotificationPreferences object with the updated values where overrides are allowed.

This functionality can be beneficial for temporarily superseding certain user preferences to ensure notifications for a specific event are delivered. Nonetheless, it is advisable to use this approach temporarily to avoid confusing users with unexpected changes to their notification settings. It is unnecessary to specify all values; only set and save the preferences that have been changed.

To mute one or more group or one-on-one conversations, utilize the CometChatNotifications.muteConversations() method. This method requires an array of MutedConversation objects, each containing the following properties:

PropertyTypeDescription
idStringThis can either be uid or guid.
typeStringThis can either be oneOnOne or group.
untilNumberThis is a valid timestamp from the future. Eg: 1710696964705.

To unmute one or more group or one-on-one conversations that were muted by the user, utilize the CometChatNotifications.unmuteConversations() method. This method requires an array of UnmutedConversation objects, each containing the following properties:

PropertyTypeDescription
idStringThis can either be uid or guid.
typeStringThis can either be oneOnOne or group.
// This is applicable for web, React native, Ionic cordova
// The example demonstrates modifying all values; however, modifying only the changed values is sufficient.

// Instantiate the NotificationPreferences.
const updatedPreferences = new NotificationPreferences();

const mutePreferences = new MutePreferences();

// Change mute preferences
mutePreferences.setDNDPreference(DNDOptions.ENABLED);

// Load the updates in the NotificationPreferences instance.
updatedPreferences.setMutePreferences(mutePreferences);

// Update the preferences and receive the udpated copy.
const notificationPreferences = await CometChatNotifications.updatePreferences(updatedPreferences);


// Mute conversations
const until = Date.now() + 86400000; // Mute for 1 day
const muteSuperhero1 = new MutedConversation();
muteSuperhero1.setId('superhero1');
muteSuperhero1.setType(MutedConversationType.ONE_ON_ONE);
muteSuperhero1.setUntil(until);

const muteSupergroup = new MutedConversation();
muteSupergroup.setId('supergroup');
muteSupergroup.setType(MutedConversationType.GROUP);
muteSupergroup.setUntil(until);

await CometChatNotifications.muteConversations([muteSuperhero1, muteSupergroup]);

// Unmute conversations
const unmuteSuperhero1 = new UnmutedConversation();
unmuteSuperhero1.setId('superhero1');
unmuteSuperhero1.setType(MutedConversationType.ONE_ON_ONE);

const unmuteList = [unmuteSuperhero1];

await CometChatNotifications.unmuteConversations(unmuteList);

Notification schedule

Dashboard configuration

Notifications will be delivered based on the specified daily timetable, adhering to the user's local time zone. Select "None" to disable Notifications for that day. For instance, this can be applied to weekends, such as Saturday and Sunday.

DayFromToCan user override?
Monday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
  • Yes (Default) - Users can configure a personalized notification schedule.
  • No
Tuesday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
Wednesday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
Thursday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
Friday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
Saturday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)
Sunday
  • 0 to 2359 (Default: 0)
  • None
  • Upto 2359 (Default: 2359)

Client-side implementation

Fetch schedule preferences

CometChatNotifications.fetchPreferences() method retrieves the notification preferences saved by the user as an instance of NotificationPreferences class. If the user has not configured any preferences, the default preferences defined by the CometChat administrator via the dashboard will be utilized.

// This is applicable for web, React native, Ionic cordova
const preferences = await CometChatNotifications.fetchPreferences();

// Display schedule preferences
const mutePreferences = preferences.getMutePreferences();
const schedulePreference = mutePreferences.getSchedulePreference();

const mondaySchedule = schedulePreference.get(DayOfWeek.MONDAY);
const tuesdaySchedule = schedulePreference.get(DayOfWeek.TUESDAY);
const wednesdaySchedule = schedulePreference.get(DayOfWeek.WEDNESDAY);
const thursdaySchedule = schedulePreference.get(DayOfWeek.THURSDAY);
const fridaySchedule = schedulePreference.get(DayOfWeek.FRIDAY);
const saturdaySchedule = schedulePreference.get(DayOfWeek.SATURDAY);
const sundaySchedule = schedulePreference.get(DayOfWeek.SUNDAY);

// This action can be performed on other days of the week.
const mondayFrom = mondaySchedule?.getFrom();
const mondayTo = mondaySchedule?.getTo();
const mondayDnd = mondaySchedule?.getDND();

Update schedule preferences

CometChatNotifications.updatePreferences() method is used to update a user's notification preferences. The "override" toggle defined in the dashboard is crucial when updating preferences. If any preference is non-overridable, the method doesn't generate an error; it instead returns the NotificationPreferences object with the updated values where overrides are allowed.

This functionality can be beneficial for temporarily superseding certain user preferences to ensure notifications for a specific event are delivered. Nonetheless, it is advisable to use this approach temporarily to avoid confusing users with unexpected changes to their notification settings.

It is unnecessary to specify all values; only set and save the preferences that have been changed.

// This is applicable for web, React native, Ionic cordova
// The example demonstrates modifying all values; however, modifying only the changed values is sufficient.

// Instantiate the NotificationPreferences.
const updatedPreferences = new NotificationPreferences();

// Instantiate the preferences that you want to update.
const mutePreferences = new MutePreferences();

// Change schedule preferences
const scheduleMap = new Map<DayOfWeek, DaySchedule>();
const mondaySchedule = new DaySchedule(2015, 2345, false);

scheduleMap.set(DayOfWeek.MONDAY, mondaySchedule);

mutePreferences.setSchedulePreference(scheduleMap);

// Load the updates in the NotificationPreferences instance.
updatedPreferences.setOneOnOnePreferences(oneOnOnePreferences);
updatedPreferences.setGroupPreferences(groupPreferences);
updatedPreferences.setMutePreferences(mutePreferences);

// Update the preferences and receive the udpated copy.
const preferences = await CometChatNotifications.updatePreferences(updatedPreferences);

Calls preferences

These preferences are configured on behalf of you for CometChat calls and cannot be modified. These don't apply for Email and SMS notifications. Only Push Notifications are triggered for:

  1. Incoming calls
  2. Missed calls
  3. Busy calls
  4. Ongoing calls
  5. Call ended
  6. Call rejected

Reset preferences

CometChatNotifications.resetPreferences() method is used to reset the preferences for a user to their default state. The default state of preferences is defined by the CometChat administrator via the dashboard.

// This is applicable for web, React native, Ionic cordova
const defaultPreferences = await CometChatNotifications.resetPreferences();

Email notification preferences

PreferenceValuesDescription
Notify for unread messages only
  • true (Default)
  • false
  • Email notifications are sent only when there are unread messages in a conversation.
  • When set to false, the notifications are sent irrespective of whether there are unread messages or not.
The interval between two emails (in minutes)

120

  • By default, the notifications are triggered after 120 minutes.
  • The minimum allowed value is 30.
  • The maximum is 1440 minutes (24 hours).
Maximum emails per day

20

  • By default, a maximum of 20 email notifications can be sent to a user on a given day.
  • The minimum value can be set to 1.
  • The maximum can be 30.
Maximum emails per conversation per day

2

  • By default, a maximum of 2 email notifications can be sent to a user for a given conversation on a given day.
  • The minimum value can be set to 1.
  • The maximum can be 30.

SMS notification preferences

PreferenceValuesDescription
Notify for unread messages only
  • true (Default)
  • false
  • SMS notifications are sent only when there are unread messages in a conversation.
  • When set to false, the notifications are sent irrespective of whether there are unread messages or not.
The interval between two emails (in minutes)

120

  • By default, the notifications are triggered after 120 minutes.
  • The minimum allowed value is 30.
  • The maximum is 1440 minutes (24 hours).
Maximum emails per day

20

  • By default, a maximum of 20 SMS notifications can be sent to a user on a given day.
  • The minimum value can be set to 1.
  • The maximum can be 30.
Maximum emails per conversation per day

2

  • By default, a maximum of 2 SMS notifications can be sent to a user for a given conversation on a given day.
  • The minimum value can be set to 1.
  • The maximum can be 30.

Common templates and sounds

Templates are designed to specify the content displayed in notifications on the user's device for different events.

Templates incorporate placeholders, which reference specific pieces of information determined by properties from the event.

For example, New message event has the following structure:

{
"data": {
"id": "17",
"conversationId": "group_supergroup",
"sender": "superhero2",
"receiverType": "group",
"receiver": "supergroup",
"category": "message",
"type": "text",
"data": {
"text": "Hello! How are you?",
"entities": {
"sender": {
"entity": {
"uid": "superhero2",
"name": "Captain America",
"role": "default",
"avatar": "https://data.cometchat.com/assets/images/avatars/captainamerica.png",
"status": "available",
"lastActiveAt": 1707901272
},
"entityType": "user"
},
"receiver": {
"entity": {
"guid": "supergroup",
"icon": "https://data.cometchat.com/assets/images/avatars/supergroup.png",
"name": "Comic Heros' Hangout",
"type": "public",
"owner": "superhero1",
"createdAt": 1706014061,
"conversationId": "group_supergroup",
"onlineMembersCount": 3
},
"entityType": "group"
}
},
},
"sentAt": 1707902030,
"updatedAt": 1707902030
}
}

The sender's name is accessible via data.entities.sender.name, so the placeholder for the sender's name will be {{message.data.entities.sender.name}}. This placeholder is substituted within the template with the actual name of the sender aka the substitution value.

As an administrator, you can configure:

  1. Default templates - Use these templates to display previews by leveraging the information contained in the event.
  2. Privacy templates - Employ these templates to present generic content in the notification.

Privacy setting

Dashboard configuration

Configure which template will be used for displaying the content of the notifications displayed on user's devices. The available preferences are:

  1. Use default template - Enforces the use of default templates for all the users.
  2. Use privacy template - Enforces the use of privacy templates for all the users.
  3. Use default templates with user privacy override (Default) - Uses default templates by default, but allows the users to enable privacy to hide the previews.

Client-side implementation

Fetch privacy setting

The method CometChatNotifications.fetchPreferences() retrieves the notification preferences saved by the user as an instance of NotificationPreferences class. If the user has not configured any preferences, the default preferences defined by the CometChat administrator via the dashboard will be utilized.

// This is applicable for web, React native, Ionic cordova
const preferences = await CometChatNotifications.fetchPreferences();

// Display a toggle for use privacy option TODO
const usePrivacyTemplate = preferences.getUsePrivacyTemplate();

Update privacy setting

CometChatNotifications.updatePreferences() method is used to update a user's notification preferences. The "override" toggle defined in the dashboard is crucial when updating preferences. If any preference is non-overridable, the method doesn't generate an error; it instead returns the NotificationPreferences object with the updated values where overrides are allowed.

This functionality can be beneficial for temporarily superseding certain user preferences to ensure notifications for a specific event are delivered. Nonetheless, it is advisable to use this approach temporarily to avoid confusing users with unexpected changes to their notification settings.

It is unnecessary to specify all values; only set and save the preferences that have been changed.

// This is applicable for web, React native, Ionic cordova
// The example demonstrates modifying all values; however, modifying only the changed values is sufficient.

// Instantiate the NotificationPreferences.
const updatedPreferences = new NotificationPreferences();

// To update the preference for privacy template
updatedPreferences.setUsePrivacyTemplate(true);

// Update the preferences and receive the udpated copy.
const notificationPreferences = await CometChatNotifications.updatePreferences(updatedPreferences);

Text message templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
Body{{message.data.text}}New message

Media message templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
Body for Image📷 Has sent an imageNew image message
Body for Audio🔈 Has sent an audioNew audio message
Body for Audio🎥 Has sent a videoNew video message
Body for Audio📄 Has sent a fileNew file message

Custom message templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
Body{{message.data.text}}{{message.data.text}}
Body (Fallback)New messageNew message

Note: The "Body (Fallback)" value is utilized when any placeholders within the "Body" fail to resolve to an appropriate substitution value.

For example, if {{message.data.text}} in the aforementioned scenario evaluates to null or undefined, the "Body (Fallback)" value will be utilized.

Ideally, the "Body (Fallback)" value should not contain any placeholders to prevent additional resolution failures.

Interactive form templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
Body{{data.interactiveData.title}}New message

Interactive card templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
Body{{data.interactiveData.title}}New message

Interactive scheduler templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
BodyNew inviteNew invite

Custom Interactive message templates

Template forDefault template valuesPrivacy template values
Title (One-on-one){{message.data.entities.sender.entity.name}}{{message.data.entities.sender.entity.name}}
Title (Group){{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}{{message.data.entities.sender.entity.name}} @ {{message.data.entities.receiver.entity.name}}
BodyNew messageNew message

Sounds

The sound files must be included within the app's bundle. These values are set within the notification payload as values of the "sound" field.

Sound for Call Notifications: Specify the name of the sound file you wish to play for call notifications.

Sound for Chat Notifications: Specify the name of the sound file you wish to play for chat notifications.

Email notification templates

You can use a default template or a privacy template in case you consider the information to be displayed as sensitive. The data available for email's subject template is as follows:

{
"to": {
"name": "Iron Man",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/ironman.png"
},
"messages": [
{
"sender": {
"uid": "superhero4",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"name": "Wolverine"
},
"message": "Are we meeting on this weekend?"
},
{
"sender": {
"uid": "superhero4",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"name": "Wolverine"
},
"message": "📷 Has shared an image"
}
],
"senderDetails": {
"name": "Wolverine",
"icon": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png"
}
}

Considering the above data, an email's subject can be formatted as follows:

Subject forTemplateFinal subject

Group notification

Hello {{to.name}}! You have {{messages.length}} message(s) in {{groupDetails.name}}.

Hello Ironman! You have 2 message(s) in Comic Heros' Hangout.

One-on-one notification

Hello {{to.name}}! You have {{messages.length}} message(s) from {{senderDetails.name}}.

Hello Ironman! You have 2 message(s) from Wolverine.

SMS notification templates

You can use a default template or a privacy template in case you consider the information to be displayed as sensitive. The data available for SMS template is as follows:

{
"to": {
"name": "Iron Man",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/ironman.png"
},
"messages": [
{
"sender": {
"uid": "superhero4",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"name": "Wolverine"
},
"message": "Are we meeting on this weekend?"
},
{
"sender": {
"uid": "superhero4",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"name": "Wolverine"
},
"message": "📷 Has shared an image"
}
],
"senderDetails": {
"name": "Wolverine",
"icon": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png"
}
}

Considering the above data, an SMS can be formatted as follows:

SMS forTemplateFinal content

Group notification

You've received {{messages.length}} message(s) in {{groupDetails.name}}! Read them at https://your-website.com.

You've received 2 message(s) in Comic Heros' Hangout! Read them at https://your-website.com.

One-on-one notification

You've received {{messages.length}} message(s) from {{senderDetails.name}}! Read them at https://your-website.com/chat.

You've received 2 message(s) from Wolverine! Read them at https://your-website.com/chat.

info

Replace https://your-website.com/chat with the URL of your actual website.