Insert messages
Insert messages into the local channel history using channel.insertMessages().
tip
- Insert a message into the local channel history.
- The message must be a storable type, otherwise a parameter error is thrown.
- Only channel type, channel ID, subchannel ID, message direction, send time, and type-specific properties are configurable.
- By default, inserted messages are marked as successfully sent messages from the sender.
- 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
| Parameter | Type | Description |
|---|---|---|
messageParamsList | List<MessageParams> | Message params to insert (e.g., TextMessageParams). |
handler | OprationHandler<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');
}
},
);