How to work with UI notifications?

I’m totally stack on this question. ExampleUI say one way to use it, descriptions from Notification class say second, source code say third way to use.

I’m try this code in index() method of my controller

public function index() {
	$notification = new Notification('Success');
	$notification->context = Notification::CONTEXT_SUCCESS;
	$notification->type = Notification::TYPE_TOAST;
	Notification\Manager::notify('myUniqueNotificationIdT', $notification);

	$view = new View('@Counter/default.twig');
	$view->topMenu = MenuTop::getInstance()->getMenu();
	$view->userMenu = MenuUser::getInstance()->getMenu();
	$view->adminMenu = MenuAdmin::getInstance()->getMenu();

	$view->notifications = $notification;

	return $view->render();

And in template

{% extends "admin.twig" %}
{% block content %}
<div id="myUniqueNotificationIdT">
	{% if notifications|length %}
		{% for notificationId, n in notifications %}
			{{ n.message|notification({'id': notificationId, 'type': n.type, 'title': n.title, 'noclear': n.hasNoClear, 'context': n.context, 'raw': n.raw}, false) }}

		{% endfor %}
	{% endif %}
{% endblock %}

But no notifications is displayed. What’s wrong?

Hi there,

this doc should be the most up to date: Notification - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

it is simply to create the notification you don’t need to write any View code. hopefully the guide above helps?

Thank you Matt. After diggin api I found the same instructions :slight_smile: Now it’s work.