Showing notifications
Notification
Notifications are banner-type messages that inform the user about system and app events. Notifications are displayed prominently at the top of the Magnolia UI. They capture the user’s attention effectively but do not interrupt what the user is currently working on. Notifications are the only persistent message type. The user can safely close the notification banner and read the full message in the Notifications app later.
Showing a notification message in app code
To show a notification message:
-
Inject
MessagesManager
into your class so that you can access the messaging convenience methods. Create a new info.magnolia.ui.api.message.Message object. Pass info.magnolia.ui.api.message.MessageType only if you want to create your own message types.
@Inject
public MyClass(MessagesManager messagesManager) {
this.messagesManager = messagesManager
}
public void handleGroupMessage(final String group, final MessageType type, final String subject, final String message) {
messagesManager.sendGroupMessage(group, new Message(type, subject, message));
}
Showing a notification to a named user
MessagesManager
provides convenience methods for sending messages. The user
will be notified instantly with a notification banner if they are
currently signed in. In any case, the message is stored in the
Notifications app.
void sendMessage(String user, Message message);
Showing a notification to all users in a group
The users in the group will be notified instantly with a notification banner if they are currently signed in. In any case, the message is stored in the Notifications app.
void sendGroupMessage(String group, Message message);
Showing a notification to the current user
The current user will be notified with a notification banner.
void sendLocalMessage(Message message);
}
Broadcast a notification message to all users
The users will be notified instantly with a notification banner if they are currently signed in. In any case, the message will be stored in the Notifications app.
void broadcastMessage(Message message);
See info.magnolia.ui.framework.message.MessagesManager for more information.
Sending a notification using the Messages app
The Messages app is a tool that
allows you to send notifications to individual users, groups or all
users. This app is only available to the superuser
role by default, as
configured in app
launcher permissions.