Neethu Ah's avatar

Notification alert with sound

is it possible to add a sound alert in larval 8

0 likes
2 replies
jimmitjoo's avatar

Yes, you probably need to broadcast your notification so you can receive it on the frontend part of your application. Then the url to a file with the sound you wish to play.

Then when a notification arrives you trigger the sound to play.

How it may look if you use Pusher for example.

let pusher = new Pusher('{{ config('broadcasting.connections.pusher.key') }}', {
    cluster: 'eu'
});
let yourSound = new Audio('https://your-website.com/sounds/notification.wav');

let channel = pusher.subscribe('your-notification-channel');
channel.bind('YourEvent', function (data) {
    // maybe update your DOM or do something else with your data...

    yourSound.play();
}
Snapey's avatar

with javascript, not with laravel

Please or to participate in this conversation.