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:
- New Message (Text, media, or Custom messages like Polls)
- Edited Message
- Deleted Message
- 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.
Parameters | Value | Description |
---|---|---|
uids | Array of UIDs | This parameter allows you to mute one-on-one chat for the mentioned UIDs. |
guids | Array of GUIDs | This parameter allows you to mute group chat for the mentioned GUIDs. |
timeInMS | String consisting of UNIX timestamp | This 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.
- Javascript
- Java
- Swift
CometChat.callExtension('push-notification', 'POST', 'v2/mute-chat', {
"uids": ["cometchat-uid-1"],
"guids": ["cometchat-guid-1"],
"timeInMS": "1628610749081"
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});
import org.json.simple.JSONObject;
JSONObject body=new JSONObject();
JSONArray uids = new JSONArray();
JSONArray guids = new JSONArray();
uids.add("cometchat-uid-1");
guids.add("cometchat-guid-1");
body.put("uids", uids);
body.put("guids", guids);
body.put("timeInMS", "1628425767881");
CometChat.callExtension("push-notification", "POST", "/v2/mute-chat", body,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/mute-chat", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"], "timeInMS":"1628610749081"] as [String : Any], onSuccess: { (response) in
// Success
}) { (error) in
// Error occured
}
Unmute Chats
Used to unmute the chats for certain conversations before the mentioned time during muting.
Parameters | Value | Description |
---|---|---|
uids | Array of UIDs | This parameter allows you to unmute one-on-one chat for the mentioned UIDs. |
guids | Array of GUIDs | This parameter allows you to unmute group chat for the mentioned GUIDs. |
This functionality uses the callExtension()
method provided by CometChat SDK.
- Javascript
- Java
- Swift
CometChat.callExtension('push-notification', 'POST', 'v2/unmute-chat', {
"uids": ["cometchat-uid-1"],
"guids": ["cometchat-guid-1"]
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});
import org.json.simple.JSONObject;
JSONObject body=new JSONObject();
JSONArray uids = new JSONArray();
JSONArray guids = new JSONArray();
uids.add("cometchat-uid-1");
guids.add("cometchat-guid-1");
body.put("uids", uids);
body.put("guids", guids);
CometChat.callExtension("push-notification", "POST", "/v2/unmute-chat", body,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/unmute-chat", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"]] as [String : Any], onSuccess: { (response) in
// Success
}) { (error) in
// 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.
Parameters | Value | Description |
---|---|---|
uids | Array of UIDs | This parameter allows you to mute one-on-one calls for the mentioned UIDs. |
guids | Array of GUIDs | This parameter allows you to mute group calls for the mentioned GUIDs. |
timeinMS | String consisting of UNIX timestamp | This 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.
- Javascript
- Java
- Swift
CometChat.callExtension('push-notification', 'POST', 'v2/mute-calls', {
"uids": ["cometchat-uid-1"],
"guids": ["cometchat-guid-1"],
"timeInMS": "1628610749081"
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});
import org.json.simple.JSONObject;
JSONObject body=new JSONObject();
JSONArray uids = new JSONArray();
JSONArray guids = new JSONArray();
uids.add("cometchat-uid-1");
guids.add("cometchat-guid-1");
body.put("uids", uids);
body.put("guids", guids);
body.put("timeInMS", "1628425767881");
CometChat.callExtension("push-notification", "POST", "/v2/mute-calls", body,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/mute-calls", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"], "timeInMS":"1628610749081"] as [String : Any], onSuccess: { (response) in
// Success
}) { (error) in
// Error occured
}
Unmute Calls
Used to unmute calls for certain conversations before the mentioned time during muting.
Parameters | Value | Description |
---|---|---|
uids | Array of UIDs | This parameter allows you to unmute one-on-one calls for the mentioned UIDs. |
guids | Array of GUIDs | This 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.
- Javascript
- Java
- Swift
CometChat.callExtension('push-notification', 'POST', 'v2/unmute-calls', {
"uids": ["cometchat-uid-1"],
"guids": ["cometchat-guid-1"]
}).then(response => {
// Success
})
.catch(error => {
// Error occured
});
import org.json.simple.JSONObject;
JSONObject body=new JSONObject();
JSONArray uids = new JSONArray();
JSONArray guids = new JSONArray();
uids.add("cometchat-uid-1");
guids.add("cometchat-guid-1");
body.put("uids", uids);
body.put("guids", guids);
CometChat.callExtension("push-notification", "POST", "/v2/unmute-calls", body,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/unmute-calls", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"]] as [String : Any], onSuccess: { (response) in
// Success
}) { (error) in
// 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:
Settings | Description |
---|---|
Do Not Disturb | When 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 Mentions | Until turned OFF, the notifications are only sent for text messages for the mentioned receiver of the message |
Mute all one-on-one chat | This 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 chat | This 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 calls | This 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 calls | This 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:
- Swift
{
"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.
- Javascript
- Java
- Swift
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
});
JSONObject chatSettings = new JSONObject();
chatSettings.put('allow_only_mentions', false);
chatSettings.put('mute_group_actions', false);
chatSettings.put('mute_all_guids', false);
chatSettings.put('mute_all_uids', false);
JSONObject callSettings = new JSONObject();
callSettings.put('mute_all_guids', false);
callSettings.put('mute_all_uids', false);
JSONObject userSettings = new JSONObject();
userSettings.put('dnd', true);
userSettings.put('chat', chatSettings);
userSettings.put('call', callSettings);
CometChat.callExtension("push-notification", "GET", "/v2/user-settings", null,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .get, endPoint: "v2/user-settings", body: {
"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
}
}
}, onSuccess: { (response) in
// Success
}) { (error) in
// 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.
- Javascript
- Java
- Swift
CometChat.callExtension('push-notification', 'GET', 'v2/user-settings', null).then(response => {
// Success
})
.catch(error => {
// Error occured
});
CometChat.callExtension("push-notification", "GET", "/v2/user-settings", null,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
//On Success
}
@Override
public void onError(CometChatException e) {
//On Failure
}
});
CometChat.callExtension(slug: "push-notification", type: .get, endPoint: "v2/user-settings", body: nil, onSuccess: { (response) in
// Success
}) { (error) in
// Error occured
}