Notifications
This guide covers how to dynamically send notifications to users when an event occurs.
Backend events and settings
Let's say we want to create a notification to send to video chat participants after a chat has completed.
In the relevant NotificationDelegate.php
:
$this->dispatcher->trigger('notification', 'all', [
'to' => [$videochat->getParticipantGuid()],
'entity' => $hostEntity,
'from' => $videochat->getHostGuid(),
'notification_view' => $videochat_complete,
'params' => [],
]);
Add your notification_view
to PushSettings.php:
class PushSettings
{
protected $types = [
...
'videochat_complete' => true,
];
Also add your notification_view
to:
- Notification/Manager.php to determine which notification category it belongs to (e.g boosts, subscriptions, votes, etc.)
- Notification/Extensions/Push.php
Frontend template
Set up the template in notification.component.html:
<ng-template ngSwitchCase="videochat_complete">
...
</ng-template>
Testing
Make sure the notification dispatcher runner is running:
docker-compose exec php-fpm php /var/www/Minds/engine/cli.php QueueRunner run --runner=NotificationDispatcher