tencent cloud

Feedback

Last updated: 2023-07-17 17:07:38

    Feature Description

    You can set the message receiving option for a one-to-one or group chat to implement the notification muting feature.
    The Chat SDK supports the following three message receiving options:
    Message Receiving Option
    Feature Description
    TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE
    Messages will be received when the user is online, and offline push notifications will be received when the user is offline.
    TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE
    The SDK receives a message and notifies you (by reporting the message receiving event), and you display no notification. This option is usually used to implement message notification muting.
    TencentCloudChat.TYPES.MSG_REMIND_DISCARD
    The SDK rejects a message.

    Setting the Conversation Message Notification Type

    Note
    1. If the message notification type is set to mute message notifications, messages will be received when the user is online and will not be received when the user is offline (with offline push supported).
    2. If the message notification type is set to reject messages, no messages will be received no matter whether the user is online or offline, and messages sent by the sender can be obtained through getMessageList.
    API
    chat.setMessageRemindType(options);
    Parameter
    The options parameter is of the Object type. It contains the following attribute values:
    Name
    Type
    Description
    groupID
    String
    Group ID or topic ID
    userIDList
    Array
    List of userID values of the receivers of the one-to-one conversation. The number of userID values cannot exceed 30 per request.
    messageRemindType
    String
    Group message notification type. Valid values:
    TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE (The SDK receives messages and notifies the receiver (by reporting the message receiving event), and a notification is displayed for the receiver.)
    TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE (The SDK receives messages and notifies the receiver (by reporting the message receiving event), and no notification is displayed. This option is usually used to implement message notification muting.)
    TencentCloudChat.TYPES.MSG_REMIND_DISCARD (The SDK rejects messages.)
    Returned value
    Promise
    Sample
    // Set to reject group messages
    // (The `getMessageList` API can be called to pull messages sent by other group members)
    let promise = chat.setMessageRemindType({
    groupID: 'group1',
    messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_DISCARD
    });
    promise.then(function(imResponse) {
    // The SDK triggers the `TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED` event
    // (after traversing the list and reading `Conversation.messageRemindType`).
    }).catch(function(imError) {
    console.warn('setMessageRemindType error:', imError);
    });
    // Enable message notifications after setting to reject group messages
    let promise = chat.setMessageRemindType({
    groupID: 'group1',
    messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE
    });
    promise.then(function(imResponse) {
    // The SDK triggers the `TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED` event
    // (after traversing the list and reading `Conversation.messageRemindType`).
    }).catch(function(imError) {
    console.warn('setMessageRemindType error:', imError);
    });
    // If the message notification type for a one-to-one conversation is set to mute message notifications
    // messages will be received when the user is online and will not be received when the user is offline
    // (with offline push supported)
    let promise = chat.setMessageRemindType({
    userIDList: ['user1', 'user2'],
    messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE
    });
    promise.then(function(imResponse) {
    // The SDK triggers the `TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED` event
    // (after traversing the list and reading `Conversation.messageRemindType`).
    const { successUserIDList, failureUserIDList } = imResponse.data;
    // List of successfully deleted `userID` values
    successUserIDList.forEach((item) => {
    const { userID } = item;
    });
    // List of `userID` values failed to be deleted
    failureUserIDList.forEach((item) => {
    const { userID, code, message } = item;
    });
    }).catch(function(imError) {
    console.warn('setMessageRemindType error:', imError);
    });
    // If the message notification type for a community topic is set to mute message notifications,
    // messages will be received when the user is online and will not be received when the user is offline
    // (with offline push supported).
    let promise = chat.setMessageRemindType({
    groupID: 'topicID',
    messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE
    });
    promise.then(function(imResponse) {
    // Message notification muting set successfully
    }).catch(function(imError) {
    // Failed to set message notification muting
    console.warn('setMessageRemindType error:', imError);
    });
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support