Skip to main content

Conversation Draft

Save Draft

  • Save a draft to a specified conversation.
  • Saving a draft will update the sentTime of the conversation, causing it to move to the top of the list.
ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";
String content = "Draft content";

RongIMClient.getInstance().saveTextMessageDraft(conversationType, targetId, content, new
ResultCallback<Boolean>() {

@Override
public void onSuccess(Boolean success) {

}

@Override
public void onError(RongIMClient.ErrorCode errorCode) {

}
})

ParameterTypeDescription
conversationTypeConversationTypeConversation type
targetIdStringConversation ID
contentStringDraft content
callbackResultCallback<Boolean>Callback interface

Get Draft

Retrieve draft content.

ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";

RongIMClient.getInstance().getTextMessageDraft(conversationType, targetId, new
ResultCallback<String>() {

@Override
public void onSuccess(String draft) {

}

@Override
public void onError(RongIMClient.ErrorCode errorCode) {

}
});

ParameterTypeDescription
conversationTypeConversationTypeConversation type
targetIdStringConversation ID
callbackResultCallback<String>Callback interface

Delete Draft

Delete a draft.

ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";

RongIMClient.getInstance().clearTextMessageDraft(conversationType, targetId, new ResultCallback<Boolean>() {

@Override
public void onSuccess(Boolean success) {

}

@Override
public void onError(RongIMClient.ErrorCode errorCode) {

}
});

ParameterTypeDescription
conversationTypeConversationTypeConversation type
targetIdStringConversation ID
callbackResultCallback<Boolean>Callback interface