Skip to main content

Recall Message

After a user successfully sends a message through the app, they may discover errors in the message content and wish to recall the message, removing it from the recipient's message history. You can use the recall message feature to meet this requirement.

recallMessage replaces the original message in the chat history with a recall notification message (objectName: RC:RcNtf) (RCRecallNotificationMessage). Meanwhile, the message recipient can receive the server notification through the messageDidRecall callback method in RCIMClientReceiveMessageDelegate. Upon receiving the recall notification, the recipient can perform corresponding actions and refresh the UI.

For details on the structure of the recall notification message, refer to the server-side documentation Notification Message Format.

By default, RC does not restrict who can recall messages. If restrictions are needed, consider the following options:

  • The app client can impose restrictions on who can recall messages. For example, regular users in the app's business logic may not be allowed to recall messages sent by others, while administrators can recall messages sent by others.
  • To prevent users from recalling messages not sent by themselves, you can submit a ticket to enable the IMLib SDK to only allow recalling messages sent by oneself. This restriction is enforced by the RC server, preventing users from recalling messages not sent by themselves.

IMLib does not impose a time limit on recalling messages. However, most mainstream social apps do enforce such limits. It is recommended that developers implement their own time limits for message recalls.

Recall Message

Recall a specific message. Only successfully sent messages can be recalled. The recall success result returns the messageId of the message, but the message has already been replaced with a recall notification gray bar message (RCRecallNotificationMessage). You can retrieve the recall notification gray bar message from the database using the messageId and display it in the UI.

[[RCIMClient sharedRCIMClient] recallMessage:msg pushContent:nil success:^(long messageId) {

} error:^(RCErrorCode errorcode) {

}];
ParameterTypeDescription
messageRCMessageThe message to be recalled
pushContentNSStringThe content displayed in the push notification
successBlockBlockCallback for successful recall. Returns the messageId of the recalled message, which has been replaced with a new recall notification gray bar message.
errorBlockBlockCallback for recall failure. RCErrorCode is the error code.

If you need to recall a message by its message ID (a unique database index value) or UID (a unique server message ID), you can first retrieve the message to be recalled using the following methods, then use recallMessage to recall it.

Listen for Message Recall Events

After the message sender calls recallMessage, the message recipient can receive the server notification through the messageDidRecall callback method in RCIMClientReceiveMessageDelegate. Upon receiving the recall notification, the recipient can perform corresponding actions and refresh the UI, or handle it accordingly.

To implement this feature, developers need to conform to the RCIMClientReceiveMessageDelegate protocol.

Set the Delegate

[[RCIMClient sharedRCIMClient] setReceiveMessageDelegate:self object:nil];

Delegate Method

The message recipient can listen for recalled messages using the following method.

@protocol RCIMClientReceiveMessageDelegate <NSObject>
/*!
Callback method for message recall

@param message The recalled message

@discussion The recalled message will be replaced with an RCRecallNotificationMessage. The app needs to refresh this message in the UI.
@discussion This method is functionally identical to the - (void)onMessageRecalled:(long)messageId method above. Only one of the two should be used.
*/
- (void)messageDidRecall:(RCMessage *)message;
@end