Laravel Echo not working: Receiving Database Notifications via Websockets
Trying to set up echo/pusher to receiving notifications on the admin panel as described here:
https://filamentphp.com/docs/3.x/notifications/database-notifications#using-echo-to-receive-new-database-notifications-with-websockets
Added the
databaseNotifications()
method to the AdminPanelProvider
, as well as set databaseNotificationsPolling()
to null
for good measure.
Installed Laravel Echo both server side and admin side:
npm install --save-dev laravel-echo pusher-js
composer require pusher/pusher-php-server
Set up my env variables to send to Pusher. Pusher dashboard shows that, yes it does receive the messages, the little chart does increase over time. But the Clients Connected
is stuck at 0.
Honestly this just might be me being a little tired at this time of the night.
Did a little bit of source diving on the notification blade code and decided to try this on the browser's console:
window.dispatchEvent(new CustomEvent('EchoLoaded'))
Result: TypeError: window.Echo is undefined
What do I need to do?3 Replies
Could it be that while you did npm install, you forgot to uncomment the resources/js/bootstrap.js or import it? Looks like echo isn't being initialised in js, and this might be the culprit
Since I'm using
filament/filament
to make my app, it is my understanding that I do not have to do that? isn't what you've described something that I would need to do if I was using the filament/notifications
package in a full custom app?
Should I uncomment it, compile it and then using a Filament render hook to add it to the HTML of the website? I guess that would work?hi, did you get this working?