insertGroupMessageToLocalStorage
Introduction
Add a message to a group chat locally.
Only supports adding a text message, while the data is text itself.
This method is mainly used for add some tips or reminds to history message list, like 'Message sent successfully', that is need for current user and unnecessary sending to other users.
The messages sent by this method will only stored locally, and lost after re-installing.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
data | string | yes | The message content. |
groupID | string | yes | The group ID. |
sender | string | yes | The sender user ID. |
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 inserted. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const insertGroupMessageToLocalStorageRes =
await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.insertGroupMessageToLocalStorage(
'data',
'groupID',
'sender'
);
if (insertGroupMessageToLocalStorageRes.code === 0) {
}