Deleting and Recalling Messages
mesibo offers a rich set of APIs for deleting, wiping, recalling or editing messages. These APIs can be utilized in various ways depending on your app logic, for example:
- Invoking the delete or wipe message API when a user taps to remove a message.
- Leveraging the message retraction APIs when a user wants to retract or modify a sent message.
- Sending disappearing messages that will be deleted after set intervals.
- Scheduling regular cleanup on app start by wiping old, unwanted messages that are no longer relevant.
- Deleting messages when user is blocked or unmatched.
There are different types of deletion:
- Deleting individual or multiple messages by message ID.
- Deleting messages for a particular user or group.
- Deleting messages older than a specified time.
- Wiping messages instead of deleting.
In this document, we describe local deletion APIs. Refer to separate sections for message retraction APIs and disappearing messages API.
Deleting an Individual Message
You can delete an individual message by calling delete()
or wipe()
API of the message.
msg.delete();
You can wipe and mark the message as deleted instead of deleting by calling:
msg.wipe();
Deleting Multiple Messages
You can delete multiple messages at once by calling one of the following APIs:
// Delete specific message IDs
Mesibo.deleteMessages(msgIds[]);
// Delete messages older than timestamp (milliseconds)
Mesibo.deleteMessages(timestamp);
// Delete messages older than duration (seconds)
Mesibo.deleteMessagesOlderThan(seconds);
Parameter | Description |
---|---|
msgids | message IDs to be deleted |
timestamp | Delete messages older than this timestamp (milliseconds) |
seconds | Delete messages older than this duration (seconds) |
Deleting Messages for a User or a Group
You can also delete messages for a specific user or group using the MesiboProfile
API:
// Delete all messages
profile.deleteMessages();
// Delete messages older than timestamp
profile.deleteMessages(timestamp);
// Delete messages older than duration
profile.deleteMessagesOlderThan(seconds);
The timestamp
and duration
parameters work the same as above.
Clearing All Messages
When you delete all messages of a user or a group messages using deleteMessages()
, that user or group will no longer appear in the message summary. If you are not familiar with message summary, please refer to
reading messages, the message summary is the last message from all the users sorted by the timestamp.
If you want the user or group to still show up in the summary, use clearMessages()
instead. This deletes all messages like deleteMessages()
, but additionally reserves an empty message that will be returned in the summary.
// Clear messages and keep user/group in summary
profile.clearMessages();
// Clear with custom timestamp
profile.clearMessages(timestamp);
The reserved empty message has a default timestamp to maintain position. But you can specify a custom timestamp:
ts | Description |
---|---|
0 | Keep original timestamp |
1 | Set max timestamp to move to top |
2 | Set min timestamp to move to bottom |
Other value | Set custom timestamp (truncated between min/max) |
The reserved empty message has the status field set to MESIBO_MSGSTATUS_EMPTY
which you can use to identify this special empty message.