Set conversation draft
Persist or clear unsent message draft text for a conversation using the OpenIM React Native SDK.
Persist unsent text as a draft for a specified conversation. Call this method when the user exits the chat screen, switches conversations, or backgrounds the application to safeguard unsaved edits:
await OpenIMSDK.setConversationDraft({
conversationID,
draftText: editorValue,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation ID to store the draft for. |
draftText | string | Yes | Draft text content. Pass an empty string "" to clear the existing draft. |
During active text input, manage ephemeral text state in memory and persist it to the SDK only upon conversation blur or screen unmount.
Return value
A resolved Promise confirms that the draft text has been persisted to local storage.
Saving a draft triggers the OnConversationChanged event. Use conversationID to locate the target conversation and merge the updated draftText and draftTextTime properties. For event listener setup, see Retrieve conversation list. Purge in-memory draft buffers when switching accounts or logging out.
Was this page helpful?