createTextMessage

Introduction

createTextMessage

Parameter details

Parameter name Parameter type Required Description
text string yes The text 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 text message created.

Code example

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


const createTextMessageRes = await TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .createTextMessage(
        'test'
    );
if (createTextMessageRes.code === 0) {

    const id = createTextMessageRes.data?.id;




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

    }
}

results matching ""

    No results matching ""