please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
React Native/
Message/
SDK
  • Run Demo
  • SDK Integration
  • Initialization
  • Login and Logout
  • Message
    • Message Overview
    • Sending Message
    • Receiving Message
    • Historical Message
    • Forwarding Message
    • Modifying Message
    • Message Inserting
    • Deleting Message
    • Clearing Messages
    • Recalling Message
    • Online Message
    • Read Receipt
    • Querying Message
    • Group @ Message
    • Targeted Group Message
    • Notification Muting
    • Message Extension
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Community Management
  • User
    • User Profile
    • Friend Management
    • Friend List
    • Blocklist
  • Offline Push
    • Offline Push
  • Local Search
    • Searching for Message
    • Searching for Friend
    • Searching Group
    • Searching for Group Member
  • Signaling
    • Signaling Management
  • Changelog
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Notification Muting

Feature Description

You can set the message receiving option for a one-to-one or group chat to implement the notification muting feature. The IM SDK supports the following three message receiving options as defined in V2TIMReceiveMessageOpt:
Message Receiving Option
Feature Description
ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE
Messages will be received when the user is online, and offline push notifications will be received when the user is offline.
ReceiveMsgOptEnum.V2TIM_NOT_RECEIVE_MESSAGE
Messages will not be received no matter whether the user is online or offline.
ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE
Messages will be received when the user is online, and offline push notifications will not be received when the user is offline.
Different V2TIMReceiveMessageOpt options can be used to implement group message notification muting: No messages will be received. After the message receiving option is set to V2TIM_NOT_RECEIVE_MESSAGE, no one-to-one or group messages will be received, and the conversation list will not be updated.
Messages will be received but will not be notified to the user, and a badge without the unread count will be displayed on the conversation list UI.
1. The message receiving option is set to V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE.
2. When the receiver receives a new one-to-one or group message and needs to update the conversation list, it can get the unread count through the unreadCount (Details) in the V2TIMConversation of the conversation.
3. The receiver displays a badge rather than the unread count when identifying the message receiving option as V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE based on the recvOpt (Details) in V2TIMConversation.
Note:
As this method requires the unread count feature, it applies only to work groups (Work) and public groups (Public). For more information on group types, see Group Overview.

Setting the Message Receiving Option for a One-to-One Chat

Call the setC2CReceiveMessageOpt API (Details) to set the message receiving option for a one-to-one chat. You can use the userIDList parameter to specify up to 30 users at a time.
Caution:
This API can be called up to 5 times every second.
Below is the sample code:
// Set not to receive messages no matter whether the user is online or offline

TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.setC2CReceiveMessageOpt(
["user1", "user2"],
ReceiveMsgOptEnum.V2TIM_NOT_RECEIVE_MESSAGE
);

Getting the Message Receiving Option for a One-to-One Chat

Call the getC2CReceiveMessageOpt API (Details) to get the message receiving option for a one-to-one chat.
Below is the sample code:
const messageOpt = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.getC2CReceiveMessageOpt(["user1", "user2"]);
messageOpt.data.forEach((element) => {
// Message receiving option
element.c2CReceiveMessageOpt;
element.userID;
});

Setting the Message Receiving Option for a Group Chat

Call the setGroupReceiveMessageOpt API (Details) to set the message receiving option for a group chat.
Below is the sample code:
TencentImSDKPlugin.v2TIMManager.getMessageManager().setGroupReceiveMessageOpt(groupID: "groupID", opt: ReceiveMsgOptEnum.V2TIM_NOT_RECEIVE_MESSAGE);

Getting the Message Receiving Option for a Group Chat

Call the getGroupsInfo API (Details) to get the V2TIMGroupInfo group profile object list. Here, the recvOpt field indicates the message receiving option for the group chat.
Below is the sample code:
const groups = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupsInfo(groupIDList: ['groupID']);
groups.data.forEach((element) => {
// Get the message receiving option of the group
element.groupInfo.recvOpt;
});