Broadcast Notification broadcastAs() #33372
Unanswered
streamingsystems
asked this question in
General
Replies: 1 comment
-
The broadcastAs() method used to exist. Illuminate/Broadcasting/BroadcastEvent.php
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have been using Laravel for a few months now but never posted here so I hope I am following the correct procedure. I think I might have found something that I wanted to run by someone.
I am using the broadcast notifications from Laravel through pusher.
I wrote all of my own message events that work great in that they go down to the Javascript perfectly. Part of my implementation is that I use the "broadcastAs" so set my own name instead of using the class name (default). I use "system.message" (and other names depending on the context).
So here is my issue. I now wanted to also send broadcast notifications via the standard Notification system (in addition to me firing my own events using broadcast(...).
However, it seems there is no way for me to set the "broadcastAs" in my Notification as it keeps sending the classname down to pusher (which causes me a problem as my code expects the broadcastAs I have set in my other classes).
After 5 hours of banging my head against the wall I went into Illuminate/Notifications/Events/BroadcastNotificationCreated.php and added:
public function broadcastAs()
{
return 'system.message';
}
(just to test).
Viola it worked great.
So it seems that a quick fix would be to just implement broadcastAs like broadcastType does -- in that it checks for the method in the notification and uses it, otherwise falls back to the default.
Thanks!
-Rob
Beta Was this translation helpful? Give feedback.
All reactions