createCustomMessage

Introduction

Create a custom message.

Parameter details

Parameter name Parameter type Required Description
data string yes The custom data of the message.
desc string no The custom description of the message.
extension string no The custom extension of the message.

Returned template

V2TimValueCallback<V2TimMsgCreateInfoResult>

{
    code: number,
    desc: string,
    data: {
        id: string,
        messageInfo: V2TimMessage,
    }
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data V2TimMsgCreateInfoResult The created custom message on local.

Code example

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


const createCustomMessageRes = await TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .createCustomMessage({
        data: '自定义data',
        desc: '自定义desc',
        extension: '自定义extension',
    });
if (createCustomMessageRes.code === 0) {
    const id = createCustomMessageRes.data?.id;




    const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
        .getMessageManager()
        .sendMessage({ id: id!, receiver: 'userID', groupID: 'groupID' });
    if (sendMessageRes.code === 0) {

        sendMessageRes.data?.customElem?.data;
        sendMessageRes.data?.customElem?.desc;
        sendMessageRes.data?.customElem?.extension;
    }
}

results matching ""

    No results matching ""