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 |
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.
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.
SUBSCRIBE
or DONT_SUBSCRIBE
. It is equivalent to “Notify” and “Don’t notify” respectively, from the dashboard preferences.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 |
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 | 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 |
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.
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 . |
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) |
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.
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.
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 |
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.
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. |
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. |
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. |
placeholders
, 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:
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.
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.
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 |
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 |
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.
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 |
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 |
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 |
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 |
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 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. |