Retracting or Modifying Sent Messages

Message retraction APIs allow users to modify or delete the sent messages. For example, to correct typos or to remove messages they didn't mean to send.

You can enable or disable different retraction features by specifying retraction policies. You can also configure the max time limit for message retraction. Any messages that are older than the retraction time limit will not be retracted. The default retraction time limit is 3600 seconds which can be set from 1 second to any arbitrarily large value. You can also set various retraction policies that we will cover later in this document.

Type of Retractions

There are various ways to retract messages:

  • Modifying messages
  • Wiping messages
  • Deleting messages
  • Deleting profile from the Contact List

Modifying Messages

The sender can modify an already sent message by updating content and sending it using sendUpdate API insetad of send API. If the message with the ID exists on the remote end from the same sender, it will be updated. If not, no action will be taken.

Note that, you MUST use sendUpdate API to modify the message. If not, the message will be considered duplicate and will be discarded.

For example,

msg.message = "This is an updated message";
msg.sendUpdate();

Deleting (recall) Messages

The sender can delete sent messages by calling the MesiboMessage.recall or Mesibo.deleteMessages API, later should be used for recalling multiple messages. The message will be deleted on the local and remote ends.

On the remote end, Mesibo_onMessageStatus will be invoked when a message is deleted by sender which can be used for updating UI, if requires.

msg.recall();

OR,

boolean Mesibo.deleteMessage(msgid, remote);
boolean Mesibo.deleteMessages(msgids, count, remote);

recall and deleteMessages take the following parameters:

ParameterDescription
msgidmessage ID to be deleted
msgidsmessage IDs to be deleted
remotetrue for deleting locally and also on remote end. false to delete only locally.

For example, in Java

Mesibo.deleteMessage(1234, true);

In iOS

[MesiboInstance deleteMessage:1234 remote:YES];

Wiping Messages

Instead of deleting, the sender can wipe an already sent message by calling wipeMessage (locally only) or wipeAndRecalllMessage (both local and remote) APIs. However, if that message was not read, it will be deleted instead. On the remote end, Mesibo_onMessageStatus will be invoked when a message is deleted by sender which can be used for updating UI, if requires.

boolean wipeMessage(long msgid);
boolean wipeMessages(long[] msgids, int count);
boolean wipeAndRecalllMessage(long msgid);
boolean wipeAndRecalllMessages(long[] msgids, int count);

Above functions take the following parameters:

ParameterDescription
msgidmessage ID to be wiped or deleted
msgidsmessage IDs to be wiped or deleted

For example,

msg.wipeAndRecalllMessage();

Deleting from the Contact List and Delete Messages

A sender can request a user to delete the sender profile from the contact list of the user, and also delete all the messages by calling MesiboProfile.requestProfileRemoval API.

On the remote end, Mesibo_onProfileUpdated will be invoked when the sender profile is deleted which can be used for updating UI, if requires.

void MesiboProfile.requestProfileRemoval();

requestProfileRemoval does not take any parameters.

Retraction Policies

The app can set the retraction policies to enable or disable certain or all retraction features. The app can also set the max interval after which the retraction of messages will not be allowed.

Retraction Interval

The app can get and set the max retraction interval by using following APIs.

int setMessageRetractionInterval(int seconds);
int getMessageRetractionInterval();

setMessageRetractionInterval takes the following parameters:

ParameterDescription
secondsseconds after which retraction will not be allowed.

The default max retraction period is 1800 seconds (30 minutes).

Mesibo.setMessageRetractionInterval(1800);

Retraction Policies

The app can enable or disable different retraction features by using setRemoteRetractionPolicy. For example, an app can disable modifying the message but can allow deleting messages remotely.

int setRemoteRetractionPolicy(long policy);

setRemoteRetractionPolicy takes the following parameters:

ParameterDescription
policycan be a logical OR combination of one or more policy flags value below

By default, all the features are enabled.

FlagDescription
0Disable Message Retraction
MESIBO_RETRACT_MODIFYAllow modifying messages
MESIBO_RETRACT_WIPEAllow wiping messages
MESIBO_RETRACT_DELETEAllow deleting messages
MESIBO_RETRACT_DELUNREAD[Future] allow deleting all unread messages
MESIBO_RETRACT_DELREAD[Future] allow deleting all unread messages
MESIBO_RETRACT_DELMEDIA[Future] allow deleting all messages with media
MESIBO_RETRACT_DELTHREAD[Future] allow deleting all messages in conversation threads
MESIBO_RETRACT_DELALLAllow deleting all messages
MESIBO_RETRACT_DELCONTACTAllow deleting senders profile and messages
Mesibo.setRemoteRetractionPolicy(MESIBO_RETRACT_MODIFY|MESIBO_RETRACT_WIPE|MESIBO_RETRACT_DELETE);

Check if a message can be Retracted

You can check if a message can be retracted using MesiboMessage.mayBeRetracted() API. This API can be used to decide if the user interface for the retraction should be shown or not. It is not always certain that message can be retracted, refer to the next section for limitations.

// returns `true` if message may be retracted, `false` otherwise
msg.mayBeRetracted();

Retraction Limitation

It is worth understanding some limitations on retraction features.

  • the retraction will not work after the configured retraction period. So if the receiver is offline for a longer duration exceeding the max retraction interval, the retraction request will be rejected.
  • If the message was forwarded, the forwarded message will not be deleted when the original message was retracted.
  • Retraction interval has no bearing on retracting contact