Skip to main content

Delete messages

Chat UI's channel page implements long-press-to-delete functionality by default, supporting both local-only message deletion and synchronized deletion of messages from both local and remote storage.

You can modify the behavior of the delete button in the long-press message menu on the channel page. See Channel page for details.

If Chat UI's existing implementation doesn't meet your requirements, you can directly use these Chat SDK capabilities:

  • Delete only local copies of specified messages (by message ID), such as +[NCBaseChannel deleteLocalMessages:completion:]
  • Delete specified messages (message objects) within a channel, such as -[NCBaseChannel deleteMessagesForMe:completion:]
  • Delete specified messages (message objects) within a channel and make them invisible to all participants, such as -[NCBaseChannel deleteMessageForAll:completion:]
tip

For core classes, APIs, and usage details, see NexconnChatUI apidoc. Note: Chat SDK methods don't provide page refresh capability. You'll need to implement custom notification mechanisms for UI updates based on your business requirements.

Listen for message deletion events

You can listen for message deletion events through the message event handler.

Objective C
[NCEngine addMessageHandlerWithIdentifier:@"message_delete_handler" handler:self];

@interface YourViewController () <NCMessageHandler>
@end

- (void)onMessageDeleted:(NCMessageDeletedEvent *)event {
NSArray<NCMessage *> *messages = event.messages;
// Update UI based on deleted messages
}