notify_widget
Provides a notifications widget that adds a notifications icon to the page for the user to access their notifications. The icons displays an iOS style red badge containing the number of unread notifications, and each notification has a click-thru link that automatically sets the notification status to read when clicked.
The module also provides a service (notify_widget.api) that has a send() method and it is this method that should be used to set up notification for users, eg.
Sending to a single user
\Drupal::service('notify_widget.api')->send(
'<module_name>',
'warning',
'Password Expiry!',
'Your password is about to expire in 5 days.',
1,
'/user/pasword'
);Sending to multiple users
\Drupal::service('notify_widget.api')->send(
'<module_name>',
'warning',
'Password Expiry!',
'Your password is about to expire in 5 days.',
[1, 2, 3],
'/user/pasword'
);The first example will set a notification for user 1 (top admin), notifying them of the fact that their password will soon expire, and the notification will link to the user password page. The first argument is the "source" argument, and can take any value, but it is suggested to use the name of the module that sets the notification. As yet, the value is unused, but may be used in the future to filter notifications.
The second example above will send the same notification, but it will go to users 1, 2, and 3.
To display the notifications on the site, go to the block layout page and add the "Notify Widget" block to a region on your site. Set the block so that it only displays for authenticated users.
The notify widget settings can be reached under Configuration > System > Notify Widget Settings, and settings include the maximum number of notifications and whether to use the CSS included with the module or not. If you choose not to use the CSS provided, you must style the notifications in your own theme.