Magnolia 6.1 reached end of life on March 31, 2021. This branch is no longer supported, see End-of-life policy.
To show a notification message:
AppContext
or SubAppContext
into your class so that you can access the messaging convenience methods. getAppContext
or getSubAppContext
inside your App or SubApp classes. If you extend the BaseSubApp
you always have access to getAppContext
and getSubAppContext
.@Inject public MySubApp(SubAppContext subAppContext, MyView view) { super(subAppContext, view); view.setListener(this); } @Override public void handleGroupMessage(final String group, final MessageType type, final String subject, final String message) { getAppContext().sendGroupMessage(group, new Message(type, subject, message)); }
AppContext
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 sendUserMessage(String user, Message message);
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);
The following code snippet does the same as shell.showNotification(messageText)
.
private void sendToCurrentUser(String messageText) { final Message message = new Message(); message.setMessage(messageText); message.setType(MessageType.INFO); messagesManager.sendLocalMessage(message); }
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 MessagesMainSubapp.java for examples.
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.
The notification is then displayed in the Notifications app: