Skip to main content

Insert messages

Insert messages into the local channel history using channel.insertMessages().

tip
  1. Insert a message into the local channel history.
  2. The message must be a storable type, otherwise a parameter error is thrown.
  3. Only channel type, channel ID, subchannel ID, message direction, send time, and type-specific properties are configurable.
  4. By default, inserted messages are marked as successfully sent messages from the sender.
  5. Pass no more than 10 messages at a time. If any single message fails, the entire request fails.

Method

Dart
Future<int> insertMessages(List<MessageParams> messageParamsList, OprationHandler<List<Message>> handler)

Parameters

ParameterTypeDescription
messageParamsListList<MessageParams>Message params to insert (e.g., TextMessageParams).
handlerOprationHandler<List<Message>>Callback receiving (insertedMessages, error).

Code example

Dart
final channel = DirectChannel('<target-user-id>');
await channel.insertMessages(
[TextMessageParams(text: 'Hello')],
(insertedMessages, error) {
if (error == null) {
print('Inserted ${insertedMessages?.length} messages');
}
},
);