Conversation Draft
IMKit supports conversation draft functionality. When users enter text in the chat UI input field but don't send it, exiting to the conversation list will display the draft prompt along with its content, triggering a refresh and reordering of the conversation list.

Usage
IMKit has built-in capabilities for retrieving conversation drafts, deleting drafts, and refreshing the UI by default—no additional API calls are required.
Customization
If the default implementation doesn't meet your needs, use the following APIs provided by IMKit and IMLib.
Save Conversation Draft
Use the core IMCenter
class in IMKit to save draft content for a specified conversation. Saving a draft updates the conversation's sentTime
, triggering a reordering of the conversation list.
Interface
IMCenter.getInstance().saveTextMessageDraft(conversationType, targetId, content, callback);
Parameters
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | Conversation type |
targetId | String | Conversation ID |
content | String | Draft text content |
callback | ResultCallback<Boolean> | Callback interface |
Sample Code
ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "conversation ID";
String content = "draft content";
IMCenter.getInstance().saveTextMessageDraft(conversationType, targetId, content, new
ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean success) {
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
}
});
Retrieve/Delete Conversation Draft
IMKit doesn't provide built-in APIs for retrieving or deleting drafts. For custom requirements, use these IMLib SDK methods:
RongIMClient#getTextMessasgeDraft()
: Retrieve conversation draftRongIMClient#clearTextMessageDraft()
: Delete conversation draft
For detailed usage, refer to the IMLib documentation Conversation Draft. Note that IMLib methods don't automatically refresh the UI—implement custom notification mechanisms as needed.