Laravel Livewire Echo configuration

  echo, events, laravel, laravel-livewire, pusher

I’ve setup a notification system with Pusher and Echo on my Laravel 8 app. It works fine, I’m able to retrieve the notification event in VanillaJS with

window.Echo.private('App.Models.User.' + User.id)
.notification((notification) => {
    if (notification.type === 'AppNotificationsJobLiked') {
        let count = document.getElementById('count');
        let number = count.innerHTML;
        number++;
        count.innerHTML = number;
    }
});

But now I want to use Livewire listeners to trigger my function, then I setup :

public function getListeners()
{
    return [
        "echo-private:App.Models.User.{$this->authId},NotificationSent" => 'notifyNewJobLiked',
    ];
}

But nothing seems to work and I have no error message.. do you have any clue what could possibly going on ?

Thank you very much ! 🙂

Source: Laravel

Leave a Reply