Message Actions

Last Edit: May 05 2020

Messages have actions. They will appear if a user long (or force) presses on a message.

Actions

  • .reactions

  • .reply

  • .edit

  • .muteUser

  • .flagMessage

  • .flagUser

  • .banUser

  • .copy

  • .delete

Customization

Properties

ChatViewController has messageActions and defaultMessageActionsproperties.

You can customize a list of message actions:

  • override defaultMessageActions in your subclass:


override var defaultMessageActions: ChatViewController.MessageAction {
    return [.reactions, .copy]
}
                    
  • change messageActions when you initialize ChatViewController:


let chatViewController = ChatViewController()
chatViewController.messageActions = [.reactions, .copy]
                    

or


class MyChatViewController: ChatViewController {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        messageActions = [.reactions, .copy]
    }
}
                    

Method

You can override long-press action with this method of ChatViewController:


open func showActions(from cell: UITableViewCell, for message: Message, locationInView: CGPoint)