Browse SDKs · React Native
SDKsReact Native

Set a conversation draft

Save a draft for a conversation.

Copy

Use setConversationDraft() to save a conversation draft. Submit the current editor content when the user leaves the chat screen, switches conversations, or is about to log out.

await OpenIMSDK.setConversationDraft({
  conversationID,
  draftText: editorValue,
});

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation ID for the draft.
draftTextstringYesDraft content. Pass an empty string to clear the draft.

Keep the editor state in the application while the user is typing, then save the latest value before leaving the screen.

Return result

After the call completes, the draft is saved. Changes to draftText and draftTextTime in the conversation list are delivered through OnConversationChanged; see Retrieve the conversation list. Clear the application's editor state when the account changes or the user logs out.