appendMessage

Introduction

Append a message to another message, used for create a set of messages, with several elements. For example, can be used to create a new message with both texts and images.

Append a message to another message, used for create a set of messages, with several elements.

Only works on the stage of creating a message.

For example, can be used to create a new message with both text and image.

Parameter details

Parameter name Parameter type Required Platform Description
createMessageBaseId String yes All The id of the base message that been appended by other messages.
createMessageAppendId String yes All The id of the message to append to another message.

Returned template

V2TimValueCallback<V2TimMessage>

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

Return value details

name type description
code int Request result: Error codes. 0 means success.
desc String The description of the failure.
data V2TimMessage The message after appended.

Code example

    V2TimValueCallback<V2TimMsgCreateInfoResult> createTextMessageRes =
        await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .createTextMessage(
              text: "test", 
            );
    V2TimValueCallback<V2TimMsgCreateInfoResult> createAppendMessageRes =
        await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .createTextMessage(
              text: "append", 
            );
    if (createTextMessageRes.code == 0 && createAppendMessageRes.code == 0) {
      String? id = createTextMessageRes.data?.id;
      String? appendId = createAppendMessageRes.data?.id;
      V2TimValueCallback<V2TimMessage> appendMessageRes =
          await TencentImSDKPlugin.v2TIMManager
              .getMessageManager()
              .appendMessage(
                  createMessageBaseId: id!, createMessageAppendId: appendId!);
      if (appendMessageRes.code == 0) {
        V2TimValueCallback<V2TimMessage> sendMessageRes =
            await TencentImSDKPlugin.v2TIMManager
                .getMessageManager()
                .sendMessage(id: id, receiver: "userID", groupID: "groupID");
        if (sendMessageRes.code == 0) {
          // append的Text消息在sendMessageRes.data.textElem.nextElem中
        }
      }
    }

results matching ""

    No results matching ""