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 | Description |
---|---|---|---|
createMessageBaseId | string | yes | The id of the base message that been appended by other messages. |
createMessageAppendId | string | yes | The id of the message to append to another message. |
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 appended. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const createTextMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTextMessage(
'test'
);
const createAppendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTextMessage(
'append'
);
if (createTextMessageRes.code === 0 && createAppendMessageRes.code === 0) {
const id = createTextMessageRes.data?.id;
const appendId = createAppendMessageRes.data?.id;
const appendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.appendMessage(id!, appendId!);
if (appendMessageRes.code === 0) {
const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.sendMessage({ id: id!, receiver: 'userID', groupID: 'groupID' });
if (sendMessageRes.code === 0) {
}
}
}