Set a conversation draft
Save or clear unsent draft text locally for a conversation.
Save unsent draft text when the user leaves a chat screen, switches conversations, or modifies input contents. Debounce frequent text changes while the user is typing, and commit the final draft immediately when navigating away.
Code example
OpenIMClient.getInstance().conversationManager.setConversationDraft(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Draft saved successfully.
}
@Override
public void onError(int code, String error) {
// code and error describe the failure.
}
},
conversationID,
editorValue
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
conversationID | String | Yes | Target conversation identifier. |
draftText | String | Yes | Draft text content. Pass an empty string "" to clear the draft. |
Return value
The successful callback indicates that the draft was saved to local conversation storage. Drafts are persisted exclusively on the local device and do not synchronize to other devices or clients.
State changes after the call
Saving or clearing a draft triggers the OnConversationListener.onConversationChanged event. Locate the conversation by conversationID and update its draftText and draftTextTime fields. For complete listener registration details, see Get the conversation list.
Was this page helpful?