Disappearing (Ephemeral) Messages
The disappearing (ephemeral) messaging feature allows the sender to control how long the receiver can view or store a message. Once the timer expires, the message is automatically deleted from both the sender and receiver sides.
You can configure this feature on a per-message basis, giving you granular control over which messages disappear and which remain permanent.
Mesibo lets you control how and when a message disappears by setting its Age. You can configure up to three types of Age intervals. Depending on your app logic, you can use one or combine all three.
Disappear in N Seconds After Sent
The sender can set a message to disappear after a fixed duration from the time it was sent, regardless of whether the recipient has received or read it.
Call the setAge API of the MesiboMessage class:
void setAge(long seconds);
setAge takes the following parameter:
| Parameter | Description |
|---|---|
| seconds | Duration in seconds after which the message will disappear. |
For example, to delete a message 2 hours (7200 seconds) after it was sent:
msg.setAge(7200);
Disappear in N Seconds After Delivered
The sender can set a message to disappear after a specific duration once it is delivered to the recipient. This guarantees the message reaches the recipient’s device before the countdown begins, though it will still be deleted even if left unread.
Call the setAgeAfterDelivered API of the MesiboMessage class:
void setAgeAfterDelivered(long seconds);
setAgeAfterDelivered takes the following parameter:
| Parameter | Description |
|---|---|
| seconds | Duration in seconds after delivery when the message will disappear. |
For example, to delete a message 1 hour (3600 seconds) after it was delivered:
msg.setAgeAfterDelivered(3600);
Disappear in N Seconds After Read
The sender can set a message to disappear after a specific duration once the recipient has read it.
Call the setAgeAfterRead API of the MesiboMessage class:
void setAgeAfterRead(long seconds);
setAgeAfterRead takes the following parameter:
| Parameter | Description |
|---|---|
| seconds | Duration in seconds after being read when the message will disappear. |
For example, to delete a message 1 second after it was read:
msg.setAgeAfterRead(1);
Note: A message is deleted on the sender side only after it has been deleted on the receiver side. If you set multiple
Ageintervals on a single message, the message will disappear as soon as the first interval expires.
Group Messaging
Disappearing messages work in both one-to-one and group chats. For group messages, the delivery or read timer starts only after all recipients have received or read the message.
For added privacy, consider disabling screenshots or screen recording in your UI while disappearing messages are displayed.
Checking Disappearing Status and Remaining Age
On the receiver side, you can check whether an incoming message is set to disappear and query how much time remains before deletion.
Check if a Message Disappears
Call isDisappearingMessage on the MesiboMessage object to check if any expiration interval is configured:
boolean isDisappearingMessage();
- Returns:
trueif the message has an expiration timer set;falseotherwise.
Get Initial and Remaining Age
You can inspect both the configured duration and the live countdown remaining before deletion:
getAge(): Returns the configured age interval in seconds (long). Returns0if no age was set.getRemainingAge(): Returns the remaining time in seconds (long) before the message is deleted. Returns0if the message does not disappear or has already expired.
long getAge();
long getRemainingAge();
For example, to display a countdown timer in your UI for a disappearing message:
if (msg.isDisappearingMessage()) {
long secondsLeft = msg.getRemainingAge();
// Update UI with remaining time
}