Skip to main content

Insert Message

Insert a Single Message

  • This feature allows you to insert a message into a local conversation.
  • The message to be inserted must be a storable message; otherwise, a parameter error exception will be thrown.
  • The message insertion feature only supports configuring the conversation type, conversation ID, channel ID, message direction, message send time, and accessible attributes unique to each message type.
  • By default, if no configuration is provided, the inserted message is a sender's message that has already been sent successfully.

Method

Future<int> insertMessage(RCIMIWMessage message, {IRCIMIWInsertMessageCallback? callback});

Parameter Description

ParameterTypeDescription
messageRCIMIWMessageThe message to be inserted
callbackIRCIMIWInsertMessageCallbackEvent callback. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods for this interface are deprecated starting 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, and the specific result needs to be implemented in the interface callback. Non-zero indicates that the current operation failed, and the interface callback will not be triggered. Refer to the error codes for detailed errors.

Code Example

IRCIMIWInsertMessageCallback? callback = IRCIMIWInsertMessageCallback(onMessageInserted: (int? code, RCIMIWMessage? message) {
//...
});

int? ret = await engine?.insertMessage(message, callback:callback);

Callback Method

  • onMessageInserted

    Listener for the result of the interface call.

Function(int? code, RCIMIWMessage? message)? onMessageInserted;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
messageRCIMIWMessageThe inserted message

Code Example

engine?.onMessageInserted = (int? code, RCIMIWMessage? message) {
//...
};

Insert Multiple Messages

  • This feature allows you to insert multiple messages into a local conversation.
  • The messages to be inserted must be storable messages; otherwise, a parameter error exception will be thrown.
  • The message insertion feature only supports configuring the conversation type, conversation ID, channel ID, message direction, message send time, and accessible attributes unique to each message type.
  • By default, if no configuration is provided, the inserted messages are sender's messages that have already been sent successfully.
  • It is recommended to insert a maximum of 10 messages at a time. If one message fails, all messages will fail to be inserted.

Method

Future<int> insertMessages(List<RCIMIWMessage> messages, {IRCIMIWInsertMessagesCallback? callback});

Parameter Description

ParameterTypeDescription
messagesList<RCIMIWMessage>The list of messages to be inserted
callbackIRCIMIWInsertMessagesCallbackEvent callback. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods for this interface are deprecated starting 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, and the specific result needs to be implemented in the interface callback. Non-zero indicates that the current operation failed, and the interface callback will not be triggered. Refer to the error codes for detailed errors.

Code Example

IRCIMIWInsertMessagesCallback? callback = IRCIMIWInsertMessagesCallback(onMessagesInserted: (int? code, List<RCIMIWMessage>? messages) {
//...
});

int? ret = await engine?.insertMessages(messages, callback:callback);

Callback Method

  • onMessagesInserted

    Listener for the result of the interface call.

Function(int? code, List<RCIMIWMessage>? messages)? onMessagesInserted;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
messagesList<RCIMIWMessage>The list of inserted messages

Code Example

engine?.onMessagesInserted = (int? code, List<RCIMIWMessage>? messages) {
//...
};