Skip to main content

Recall Message

The IMKit SDK has built-in logic for message recall and display by default, eliminating the need for additional API calls related to conversations. If the existing implementation doesn't meet your requirements, you can use the relevant APIs in IMKit.

Recall Message

RCConversationViewController provides a direct API for recalling messages. Only successfully sent messages stored in the database can be recalled.

Interface Prototype

- (void)recallMessage:(long)messageId;

Parameter Description

ParameterTypeDescription
messageIdlongDatabase index value of the recalled message

Listen for Message Recall Events by Others

Recall monitoring supports both notification and delegate approaches.

Notification Monitoring

When a message is recalled, the SDK dispatches the RCKitDispatchRecallMessageNotification.

FOUNDATION_EXPORT NSString *const RCKitDispatchRecallMessageNotification;
  1. Register for the RCKitDispatchRecallMessageNotification:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(didRecallMessageNotification:)
name:RCKitDispatchRecallMessageNotification
object:nil];
  1. Implement the notification handler: The Notification's object is an NSNumber value of the message ID.
- (void)didRecallMessageNotification:(NSNotification *)notification {
long long messageId = [notification.object longLongValue];
}

Delegate Monitoring

Set a delegate conforming to the RCIMReceiveMessageDelegate protocol to listen for message recall events. This protocol is also used for receiving messages. For details, refer to Receive Messages.

@protocol RCIMReceiveMessageDelegate <NSObject>
/*!
Callback when a message is recalled

@param message The recalled message

@discussion The recalled message will be converted to RCRecallNotificationMessage. Refresh this message in your UI.
@discussion This method has identical functionality to - (void)onRCIMMessageRecalled:(long)messageId. Choose only one to implement.
*/
- (void)messageDidRecall:(RCMessage *)message;
@end