Skip to main content
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.

Push payload message options

These control what CometChat includes in push payloads. All are optional toggles:
  • Include entire message object in payload
  • Include message metadata in payload
  • Include sender’s metadata in payload
  • Include receiver’s metadata in payload
  • Trim CometChat message object (strip down to stay within provider limits)
  • Additional data in payload (JSON you add)
Use a minimal combination to stay under ~4 KB for FCM/APNs.

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• 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 actionsA member leavesDon’t notify (Default)
• Notify
Yes (Default)
• No
A new member is addedDon’t notify (Default)
• Notify
Yes (Default)
• No
A new member joinsDon’t notify (Default)
• Notify
Yes (Default)
• No
A member is kickedDon’t notify (Default)
• Notify
Yes (Default)
• No
A member is bannedDon’t notify (Default)
• Notify
Yes (Default)
• No
A member is unbannedDon’t notify (Default)
• Notify
Yes (Default)
• No
A member’s scope changesDon’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 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();
2. 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.
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• 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
// 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();
2. 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 conversationsYes (Default) - Users can mute notifications for chosen group conversations for a specified duration.
• No
Mute one-on-one conversationsYes (Default) - Users can mute notifications for chosen one-on-one conversations for a specified duration.
• No

Client-side implementation

1. 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();
2. 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 mutedUser = new MutedConversation();
mutedUser.setId('cometchat-uid-1');
mutedUser.setType(CometChatNotifications.MutedConversationType.ONE_ON_ONE);
mutedUser.setUntil(until);

const mutedGroup = new MutedConversation();
mutedGroup.setId('cometchat-guid-1');
mutedGroup.setType(CometChatNotifications.MutedConversationType.GROUP);
mutedGroup.setUntil(until);

await CometChatNotifications.muteConversations([mutedUser, mutedGroup]);

// Unmute conversations
const unmutedUser = new UnmutedConversation();
unmutedUser.setId('cometchat-uid-1');
unmutedUser.setType(CometChatNotifications.MutedConversationType.ONE_ON_ONE);

const unmuteList = [unmutedUser];

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

1. 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();
2. 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);

Bypass preferences for mentions

If this setting is enabled, 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.

Bypass preferences for @all

If this setting is enabled, end users who have enabled Do Not Disturb (DND), muted a conversation, or set up a schedule will still receive notifications when @all (a mention that notifies all group members) is used in a group message. This ensures all group members are notified regardless of their individual notification preferences.

Calls preferences

Push notifications are triggered for calling events. These notifications are not delivered via Email or SMS.
EventsAvailable preferencesCan 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.
// This is applicable for web, React native, Ionic cordova
const defaultPreferences = await CometChatNotifications.resetPreferences();