Skip to main content

Mute Functionality

Learn how to enable your users to mute notifications for certain conversations

You can silence one-on-one and/or group conversations for a specific amount of time using the Mute functionality. Aside from that, you can include a Push Notifications section in your apps' settings. Your users can use this feature to turn off Push Notifications for certain chats or to opt-out of receiving Push Notifications altogether.

Mute or Unmute Chats

Chat comprises anything related to messages like:

  1. New Message (Text, media, or Custom messages like Polls)
  2. Edited Message
  3. Deleted Message
  4. Response in threads

Mute Chats

You can specify the UIDs and/or GUIDs to be muted. You can mute chats for these conversations for a specific amount of time.

ParametersValueDescription
uidsArray of UIDsThis parameter allows you to mute one-on-one chat for the mentioned UIDs.
guidsArray of GUIDsThis parameter allows you to mute group chat for the mentioned GUIDs.
timeInMSString consisting of UNIX timestampThis parameter allows you to mute chats for a specific amount of time for the required UIDs or GUIDs

After the mentioned duration, the Push Notifications are received.

Eg: "1628425767881"

This functionality uses the callExtension() method provided by CometChat SDK.

CometChat.callExtension('push-notification', 'POST', 'v2/mute-chat', {
"uids": ["superhero1"],
"guids": ["supergroup"],
"timeInMS": "1628610749081"
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});

Unmute Chats

Used to unmute the chats for certain conversations before the mentioned time during muting.

ParametersValueDescription
uidsArray of UIDsThis parameter allows you to unmute one-on-one chat for the mentioned UIDs.
guidsArray of GUIDsThis parameter allows you to unmute group chat for the mentioned GUIDs.

This functionality uses the callExtension() method provided by CometChat SDK.

CometChat.callExtension('push-notification', 'POST', 'v2/unmute-chat', {
"uids": ["superhero1"],
"guids": ["supergroup"]
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});

Mute or Unmute Calls

You can mute the notifications for one-on-one or group calls. This works for Default calling (video or audio calls) offered by CometChat.

Mute Calls

You can specify the UIDs and/or GUIDs to be muted. You can mute calls for these conversations for the said amount of time.

ParametersValueDescription
uidsArray of UIDsThis parameter allows you to mute one-on-one calls for the mentioned UIDs.
guidsArray of GUIDsThis parameter allows you to mute group calls for the mentioned GUIDs.
timeinMSString consisting of UNIX timestampThis parameter allows you to mute calls for a specific amount of time for the required UIDs or GUIDs

After the mentioned duration, the Push Notifications are received.

Eg: "1628425767881"

This functionality uses the callExtension() method provided by CometChat SDK.

CometChat.callExtension('push-notification', 'POST', 'v2/mute-calls', {
"uids": ["superhero1"],
"guids": ["supergroup"],
"timeInMS": "1628610749081"
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});

Unmute Calls

Used to unmute calls for certain conversations before the mentioned time during muting.

ParametersValueDescription
uidsArray of UIDsThis parameter allows you to unmute one-on-one calls for the mentioned UIDs.
guidsArray of GUIDsThis parameter allows you to unmute group calls for the mentioned GUIDs.

Used to unmute the calls for certain conversations before the mentioned time during muting.

CometChat.callExtension('push-notification', 'POST', 'v2/unmute-calls', {
"uids": ["superhero1"],
"guids": ["supergroup"]
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});

User Settings

Apart from the feature to mute/unmute a set of UIDs or GUIDs using the above APIs, apps can have push notifications according to the user settings.

The following user settings can be set:

SettingsDescription
Do Not DisturbWhen turned ON, the "Do Not Disturb" parameter disables the Push Notifications entirely for the user. The user stops receiving push notifications until this setting is explicitly turned OFF. This overrides all the following settings.
Allow only MentionsUntil turned OFF, the notifications are only sent for text messages for the mentioned receiver of the message
Mute all one-on-one chatThis parameter can be used to mute chat notifications for all one-on-one conversations. The user will not receive push notifications until this is turned OFF.
Mute all group chatThis parameter can be used to mute chat notifications for all group conversations. The user will not receive push notifications until the parameter is turned OFF.
Mute all one-on-one callsThis preference can be used to mute call notifications for all one-on-one conversations. The user will not receive push notifications until the parameter is turned OFF.
Mute all group callsThis parameter can be used to mute call notifications for all group conversations. The user will not receive push notifications until this is turned OFF.

Save User Settings

The User settings object needs to be submitted as follows. All the fields are mandatory:

{
"user-settings": {
"dnd": true_false,
"chat": {
"allow_only_mentions": true_false,
"mute_group_actions": true_false,
"mute_all_guids": true_false,
"mute_all_uids": true_false
},
"call": {
"mute_all_guids": true_false,
"mute_all_uids":true_false
}
}
}

This functionality uses the callExtension() method provided by CometChat SDK.

const userSettings = {
"user-settings": {
"dnd": false,
"chat": {
"allow_only_mentions": true,
"mute_group_actions": false,
"mute_all_guids": false,
"mute_all_uids": false
},
"call": {
"mute_all_guids": false,
"mute_all_uids":false
}
}
};
CometChat.callExtension('push-notification', 'POST', 'v2/user-settings', userSettings).then(response => {
// Success
})
.catch(error => {
// Error occured
});

Fetch User Settings

Fetches all the user settings that are saved by the user. This also returns the list of muted UIDs and GUIDs along with the said time for muting.

This functionality uses the callExtension() method provided by CometChat SDK.

CometChat.callExtension('push-notification', 'GET', 'v2/user-settings', null).then(response => {
// Success
})
.catch(error => {
// Error occured
});