Delete messages
Community channel messages are stored on the server (free storage for 7 days) and in the local database. Users can delete messages from their own history — locally only or from the server only.
tip
- Deleting messages only removes them from the current user's history, without affecting other users.
- To permanently delete a message for all community members, use the recall message feature.
Delete messages before a timestamp (all subchannels)
Delete local messages across all subchannels of a community channel before a specified timestamp.
Dart
final community = CommunityChannel('<community-id>');
await community.clearMessagesForAllChannel(
<cutoff-timestamp>,
(error) {
if (error == null) {
print('All subchannel messages cleared');
}
},
);
Delete messages before a timestamp (specific subchannel)
Delete messages in a specific subchannel before a timestamp.
Dart
final subChannel = CommunitySubChannel('<community-id>', '<subchannel-id>');
await subChannel.clearSubChannelMessages(
ClearSubChannelMessagesParams(
timestamp: <cutoff-timestamp>,
policy: MessageOperationPolicy.local,
),
(error) {
if (error == null) {
print('Subchannel messages cleared');
}
},
);