reSendMessage

Introduction

Re-send a message.

You are supposed to invoke this method, to re-send a message failed to sent in previous, may as the reason of bad network conditions, or other restrictions.

The actual failure reason can refer to the error code.

The original message needs to be deleted, before re-send it.

Parameter details

Parameter name Parameter type Required Description
msgID string yes The id of the message to re-send.
onlineUserOnly boolean no Should only send the message to online users.

Returned template

V2TimValueCallback<V2TimMessage>

{
    code : number
    desc : string
    data : {
      msgID: string
      timestamp: number
      progress: number
      sender: string
      nickName: string
      friendRemark: string
      faceUrl: string
      nameCard: string
      groupID: string
      userID: string
      status: number
      elemType: number
      textElem: V2TimTextElem
      customElem: V2TimCustomElem
      imageElem: V2TimImageElem
      soundElem: V2TimSoundElem
      videoElem: V2TimVideoElem
      fileElem: V2TimFileElem
      locationElem: V2TimLocationElem
      faceElem: V2TimFaceElem
      groupTipsElem: V2TimGroupTipsElem
      mergerElem: V2TimMergerElem
      localCustomData: string
      localCustomInt: number
      cloudCustomData: string
      isSelf: boolean
      isRead: boolean
      isPeerRead: boolean
      priority: number
      offlinePushInfo: V2TimOfflinePushInfo
      groupAtUserList: string[]
      seq: string
      random: number
      isExcludedFromUnreadCount: boolean
      isExcludedFromLastMessage: boolean
      id: string
      needReadReceipt: boolean
    }
}

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 V2TimMessage The message after re-send.

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) {

    } else {
        const reSendMessageRes = await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .reSendMessage(
                id!,
                false
            );
        if (reSendMessageRes.code === 0) {

        }
    }
}

results matching ""

    No results matching ""