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.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.
- JavaScript
- Android
- iOS
- Flutter
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.- JavaScript
- Android
- iOS
- Flutter
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.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
- JavaScript
- Android
- iOS
- Flutter
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.
- JavaScript
- Android
- iOS
- Flutter
Mute preferences
Dashboard configuration
These preferences allow you to control whether the users will be able to modify mute preferences.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.
- JavaScript
- Android
- iOS
- Flutter
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:
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:
- JavaScript
- Android
- iOS
- Flutter
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.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.
- JavaScript
- Android
- iOS
- Flutter
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.
- JavaScript
- Android
- iOS
- Flutter
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.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.
- JavaScript
- Android
- iOS
- Flutter
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.
Email notification preferences
SMS notification preferences
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.
- JavaScript
- Android
- iOS
- Flutter
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.
- JavaScript
- Android
- iOS
- Flutter
Text message templates
Media message templates
Custom message templates
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
Interactive card templates
Interactive scheduler templates
Custom Interactive message templates
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:- For one-on-one conversation
- For group conversation
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:- For one-on-one conversation
- For group conversation
Replace https://your-website.com/chat with the URL of your actual website.