Skip to content

09 Notifications

CraigD edited this page Jun 30, 2024 · 4 revisions

NOTE** This has been remove as of v4.0.0


As of v2.6.2 Material can send notifications from the LMS side to the web-app. Notifications are invoked by sending JSONRPC messages to LMS. For example, this can be accomplished with curl as follows:

curl 'http://localhost:9000/jsonrpc.js' --data-raw '{"id":0,"method":"slim.request","params":["",["material-skin", "send-notif", "type:alert", "msg:The message"]]}'
  • The type parameter accepts 5 values:
    • type:info shows a brief message
    • type:error shows a brief error (red background) message
    • type:alert shows the message within a dialog
    • type:update shows an update available icon next to main menu button and info in the 'Information' dialog
    • type:notif adds an 'bell' icon next to the main menu button (unless there are updates, in which case the update icon takes precedence) and adds a 'Notifications' entry to the main menu. This menu entry will then show a 'Notifications' dialog where the notifications are listed.
  • The message body itself is sent with the msg parameter.
  • cancelable:1 can be passed with type:alert, or type:notif, to allow user to cancel these. type:alert notifications are cancelled via the 'Cancel' button on the dialog, and type:notif notifications are cancelled via the cancel icon next to the relevant list entry.
  • title:string needs to be passed with type:update to provide the title text shown in the 'Information' dialog, and to type:notif messages where it is used as the list entry title.
  • id:string needs to be passed with type:notif to uniquely identify a notification, as there can be multiple of these.
  • client:id (e.g. client:01:02:03:04:05:06) may be passed with type:error or type:info to restrict the display to Material instances that currently have the specified player as the active player.
  • timeout:seconds may be passed with type:error or type:info to control how long these are shown for.

type:alert, type:update, and type:notif messages are 'remembered' by the LMS side. When a new instance of the web-app is started, or the page refreshed, the web-app will query LMS for the last notification and will show these again. To clear these you need to send a type:alert, or type:update, message with msg:- as the message parameter.

Invoking an action from actions.json

The message part of a notification can be HTML code, and within this you may insert links that when clicked will invoke an action from actions.json. For example, the following would show "Click me" in a dialog box, and when "Click me" is clicked the action within the notifications section of actions.json that has "id":"xxx" will be invoked.

curl 'http://localhost:9000/jsonrpc.js' --data-raw '{"id":0,"method":"slim.request","params":["",["material-skin", "send-notif", "type:notif", "msg:A new version of xyz is available. <a href=\"msk:xxx\">Click</a>" to udpdate", "title:XYZ Update", "id:123"]]}'
Clone this wiki locally