removeAdvancedMsgListener

Introduction

Remove an specific advanced message listener.

All the advanced message listeners will be removed if no provided a specific listener.

Parameter details

Parameter name Parameter type Required Description
listener V2TimAdvancedMsgListener no The listener to remove.

Returned template

void

Return value details

This function has no return value

Code example

import {
    TencentImSDKPlugin,
    V2TimAdvancedMsgListener,
    MessageElemType,
} from 'react-native-tim-js';


const listener: V2TimAdvancedMsgListener = {
    onRecvC2CReadReceipt: (receiptList) => {

    },
    onRecvMessageModified: (message) => {

    },
    onRecvMessageReadReceipts: (receiptList) => {

        receiptList.forEach((element) => {
            element.groupID;
            element.msgID;
            element.readCount;
            element.unreadCount;
            element.userID;
        });
    },
    onRecvMessageRevoked: (messageid) => {

    },
    onRecvNewMessage: async (message) => {

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_TEXT) {
            message.textElem?.text;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_CUSTOM) {
            message.customElem?.data;
            message.customElem?.desc;
            message.customElem?.extension;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_IMAGE) {
            message.imageElem?.path;
            message.imageElem?.imageList?.forEach((element) => {


                element?.height;
                element?.localUrl;
                element?.size;
                element?.type;
                element?.url;
                element?.uuid;
                element?.width;
            });
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_VIDEO) {

            message.videoElem?.UUID;
            message.videoElem?.duration;
            message.videoElem?.localSnapshotUrl;
            message.videoElem?.localVideoUrl;
            message.videoElem?.snapshotHeight;
            message.videoElem?.snapshotPath;

        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_SOUND) {

            message.soundElem?.UUID;
            message.soundElem?.dataSize;
            message.soundElem?.duration;
            message.soundElem?.localUrl;
            message.soundElem?.url;

        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_FILE) {

            message.fileElem?.UUID;
            message.fileElem?.fileName;
            message.fileElem?.fileSize;
            message.fileElem?.localUrl;
            message.fileElem?.path;
            message.fileElem?.url;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_LOCATION) {

            message.locationElem?.desc;
            message.locationElem?.latitude;
            message.locationElem?.longitude;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_FACE) {
            message.faceElem?.data;
            message.faceElem?.index;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_GROUP_TIPS) {
            message.groupTipsElem?.groupID;
            message.groupTipsElem?.type;
            message.groupTipsElem?.opMember;
            message.groupTipsElem?.memberList;
            message.groupTipsElem?.groupChangeInfoList;
            message.groupTipsElem?.memberChangeInfoList;
            message.groupTipsElem?.memberCount;
        }

        if (message.elemType === MessageElemType.V2TIM_ELEM_TYPE_MERGER) {
            message.mergerElem?.abstractList;
            message.mergerElem?.isLayersOverLimit;
            message.mergerElem?.title;
            const download = await TencentImSDKPlugin.v2TIMManager
                .getMessageManager()
                .downloadMergerMessage(message.msgID!);
            if (download.code === 0) {
                const messageList = download.data;
            }
        }
    },
    onSendMessageProgress: (message, progress) => {

    },
};

TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .addAdvancedMsgListener(listener);

TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .removeAdvancedMsgListener(listener);

results matching ""

    No results matching ""