Show message using MessageInterface in Magento 2 

For showing the message using MessageInterface, please follow the below instructions:

Add this code to your file:

protected _messageManager;

public function __construct(
    \Magento\Framework\View\Element\Template\Context $context, 
    \Magento\Framework\Message\ManagerInterface $messageManager
) {
    parent::__construct($context);
    $this->_messageManager = $messageManager;
}

Then you can use below methods for showing the message

$this->_messageManager->addError(__("Error Message"));
$this->_messageManager->addWarning(__("Warning"));
$this->_messageManager->addNotice(__("Notice"));
$this->_messageManager->addSuccess(__("Success Message"));

Show message using MessageInterface in Magento 2 expoundsofttechsolution

ghb