会话草稿
保存草稿
调用 saveTextMessageDraft 方法,保存消息草稿。
接口
JavaScript
RongIMLib.saveTextMessageDraft(conversation, draft)
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversation | IConversationOption | 是 | 目标会话 |
draft | String | 是 | 草稿内容 |
示例代码
JavaScript
const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE,
targetId: '接收方的 userId'
}
const draft = '草稿内容'
RongIMLib.saveTextMessageDraft(conversation, draft).then(res => {
// 保存成功
if(res.code === 0){
console.log(res)
} else {
console.log(res.code, res.msg)
}
})
获取草稿
调用 getTextMessageDraft 方法,获取消息草稿。
接口
JavaScript
RongIMLib.getTextMessageDraft(conversation)
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversation | IConversationOption | 是 | 目标会话 |
示例代码
JavaScript
const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE,
targetId: '接收方的 userId'
}
RongIMLib.getTextMessageDraft(conversation).then(res => {
// 获取草稿成功
if( res.code === 0 ) {
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
})
删除草稿
调用 clearTextMessageDraft 方法,删除消息草稿。
接口
JavaScript
RongIMLib.clearTextMessageDraft(conversation)
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversation | IConversationOption | 是 | 目标会话 |
示例代码
JavaScript
const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE,
targetId: '接收方的 userId'
}
RongIMLib.clearTextMessageDraft(conversation).then(res => {
// 获取草稿成功
if( res.code === 0 ) {
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
})