Common Preferences
Login to CometChat dashboard and navigate to the Notifications section. Under Preferences tab, set the 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.Categories | Events | Available preferences | Can user override? |
---|---|---|---|
Conversations | New 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 actions | Message is edited | • Don’t notify • Notify (Default) | • Yes • No (Default) |
Message is deleted | • Don’t notify • Notify (Default) | • 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 actions | A 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 |
Regarding Message edited & Message deleted eventsPush notifications should be triggered for the message edited and message deleted events in order to retract the notification displaying the original message. Turning them off is not recommended.
Client-side implementation
1. Fetch group preferencesCometChatNotifications.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.
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.
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.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.Categories | Events | Available preferences | Can user override? |
---|---|---|---|
Conversations | New 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 actions | Message is edited | • Don’t notify • Notify (Default) | - Yes • No (Default) |
Message is deleted | • Don’t notify • Notify (Default) | - 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 |
Regarding Message edited & Message deleted eventsPush notifications should be triggered for the message edited and message deleted events in order to retract the notification displaying the original message. Turning them off is not recommended.
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.
1. Fetch 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.
Mute preferences
Dashboard configuration
These preferences allow you to control whether the users will be able to modify mute preferences.Mute preferences | Can 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
1. Fetch mute preferencesCometChatNotifications.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.
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:
Property | Type | Description |
---|---|---|
id | String | This can either be uid or guid . |
type | String | This can either be oneOnOne or group . |
until | Number | This is a valid timestamp from the future. Eg: 1710696964705. |
CometChatNotifications.unmuteConversations()
method. This method requires an array of UnmutedConversation
objects, each containing the following properties:
Property | Type | Description |
---|---|---|
id | String | This can either be uid or guid . |
type | String | This can either be oneOnOne or group . |
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.Day | From | To | Can 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
1. Fetch schedule preferencesCometChatNotifications.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.
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.
Bypass preferences for mentions
End users who have enabled Do Not Disturb (DND), muted a conversation, or set up a schedule will still receive notifications when they are mentioned in a new message or reply, if this setting is enabled.Calls preferences
Push notifications are triggered for calling events. These notifications are not delivered via Email or SMS.Events | Available preferences | Can user override? |
---|---|---|
Call initiated | • Don’t notify • Notify (Default) | No |
Call ongoing | • Don’t notify • Notify (Default) | No |
Call cancelled | • Don’t notify • Notify (Default) | No |
Call rejected | • Don’t notify • Notify (Default) | No |
Call unanswered | • Don’t notify • Notify (Default) | No |
Call busy | • Don’t notify • Notify (Default) | No |
Call ended | • Don’t notify • Notify (Default) | No |
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.
Push notification preferences
The notification payload sent to FCM, APNs, or custom providers can be customized to include the CometChat message object for new messages and replies. To comply with the 4 KB payload size limit required by FCM and APNs, specific parts of the message object can be excluded to reduce the payload size. Additionally, a custom payload in the form of a JSON object can be included in the push payload.
Payload setting | Available preferences |
---|---|
Include CometChat message object | • false (Default) • true |
Include Sender’s metadata | • false • true (Default) |
Include Receiver’s metadata | • false • true (Default) |
Include message metadata | • false • true (Default) |
Trim CometChat text message | • false (Default) • true |
Custom JSON | No defaults for this value. If not set, this key is not included. |
Email notification preferences
Preference | Values | Description |
---|---|---|
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 1 minute. • 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. |
Include CometChat message object | • false (Default) • true | If enabled, the message object will be included in the email notification payload. |
Include Sender’s metadata | • false (Default) • true | If enabled, the sender’s metadata will be included in the message object (applicable only when the message object is included). |
Include Receiver’s metadata | • false (Default) • true | If enabled, the receiver’s metadata will be included in the message object (applicable only when the message object is included). |
Include message metadata | • false (Default) • true | If enabled, the message metadata will be included in the message object (applicable only when the message object is included). |
SMS notification preferences
Preference | Values | Description |
---|---|---|
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 1 minute. • The maximum is 1440 minutes (24 hours). |
Maximum SMS 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 SMS 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. |
Include CometChat message object | • false (Default) • true | If enabled, the message object will be included in the SMS notification payload. |
Include Sender’s metadata | • false (Default) • true | If enabled, the sender’s metadata will be included in the message object (applicable only when the message object is included). |
Include Receiver’s metadata | • false (Default) • true | If enabled, the receiver’s metadata will be included in the message object (applicable only when the message object is included). |
Include message metadata | • false (Default) • true | If enabled, the message metadata will be included in the message object (applicable only when the message object is included). |
Common templates and sounds
Templates are designed to specify the content displayed in notifications on the user’s device for different events. Templates incorporateplaceholders
, which reference specific pieces of information determined by properties from the event.
For example, New message event has the following structure:
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:
- Default templates - Use these templates to display previews by leveraging the information contained in the event.
- 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:- Use default template - Enforces the use of default templates for all the users.
- Use privacy template - Enforces the use of privacy templates for all the users.
- 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
1. Fetch privacy setting The methodCometChatNotifications.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.
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.
Text message templates
Template for | Default template values | Privacy 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 for | Default template values | Privacy 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 image | New image message |
Body for Audio | 🔈 Has sent an audio | New audio message |
Body for Audio | 🎥 Has sent a video | New video message |
Body for Audio | 📄 Has sent a file | New file message |
Custom message templates
Template for | Default template values | Privacy 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 message | New message |
{{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 for | Default template values | Privacy 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 for | Default template values | Privacy 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 for | Default template values | Privacy 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 | New invite | New invite |
Custom Interactive message templates
Template for | Default template values | Privacy 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 | New message | New 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:Subject for | Template | Final subject |
---|---|---|
Group notification | Hello {{to.name}} ! You have {{messages.length}} message(s) in {{groupDetails.name}} . | Hello Andrew Joseph! You have 2 message(s) in Hiking Group. |
One-on-one notification | Hello {{to.name}} ! You have {{messages.length}} message(s) from {{senderDetails.name}} . | Hello Andrew Joseph! You have 2 message(s) from Susan Marie. |
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:SMS for | Template | Final 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 Hiking Group! 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 Susan Marie! Read them at https://your-website.com/chat. |
Replace https://your-website.com/chat with the URL of your actual website.