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
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
draft | String | The text content of the draft. |
callback | IRCIMIWSaveDraftMessageCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | The status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
draft | String | Draft 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
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
callback | IRCIMIWGetDraftMessageCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | The status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
draft | String | Draft 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
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
callback | IRCIMIWClearDraftMessageCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | The status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
Code Example
engine?.onDraftMessageCleared = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId) {
//...
};