Skip to main content

Conversation Draft

Save Draft

  • Save a draft message to a specified conversation.
  • Saving a draft updates the conversation's sentTime, which moves the conversation to the top of the list.

Method

Future<int> saveDraftMessage(RCIMIWConversationType type, String targetId, String? channelId, String draft, {IRCIMIWSaveDraftMessageCallback? callback});

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
draftStringThe text content of the draft.
callbackIRCIMIWSaveDraftMessageCallbackEvent callback. SDK supports callback method from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. For specific results, implement the interface callback. Non-zero values indicate failure, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWSaveDraftMessageCallback? callback = IRCIMIWSaveDraftMessageCallback(onDraftMessageSaved: (int? code) {
//...
});

int? ret = await engine?.saveDraftMessage(type, targetId, channelId, draft, callback:callback);

Callback Method

  • onDraftMessageSaved
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? draft)? onDraftMessageSaved;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
draftStringDraft information

Code Example

engine?.onDraftMessageSaved = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? draft) {
//...
};

Get Draft

Retrieve the draft content.

Method

Future<int> getDraftMessage(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWGetDraftMessageCallback? callback});

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetDraftMessageCallbackEvent callback. SDK supports callback method from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. For specific results, implement the interface callback. Non-zero values indicate failure, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWGetDraftMessageCallback? callback = IRCIMIWGetDraftMessageCallback(onSuccess: (String? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getDraftMessage(type, targetId, channelId, callback:callback);

Callback Method

  • onDraftMessageLoaded
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? draft)? onDraftMessageLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
draftStringDraft information

Code Example

engine?.onDraftMessageLoaded = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? draft) {
//...
};

Delete Draft

Clear the draft information of a conversation.

Method

Future<int> clearDraftMessage(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWClearDraftMessageCallback? callback});

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWClearDraftMessageCallbackEvent callback. SDK supports callback method from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. For specific results, implement the interface callback. Non-zero values indicate failure, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

Future<int> clearDraftMessage(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWClearDraftMessageCallback? callback});

Callback Method

  • onDraftMessageCleared
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId)? onDraftMessageCleared;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.

Code Example

engine?.onDraftMessageCleared = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId) {
//...
};