Issue
I am building a facebook clone using laravel and I want to implement a chat application. Currently two people can chat by using event broadcasting, more exactly I have created a MessageCreated event that is broadcasted using pusher and laravel echo. However, when a user doesn't have the chat box open (doesn't listen to that channel) I want to create a notification. I have seen that Laravel has Notifications and I can broadcast these. What are your suggestions for implementing something like this ? Thanks a lot
Solution
Echo can listen to broadcast events whether or not the user is seeing a chat (modal?) on the front-end. So, you should be able to broadcast events, in whatever way you are implementing them for your chat. Alternatively, as you say, you can use laravel notifications -- its BroadcastNotifications is just a wrapper for this same functionality. I would recommend doing the latter, since its standard Laravel practice/design. https://laravel.com/docs/8.x/notifications#broadcast-notifications
Beyond this trade off, I don't see what other options you're considering.
Answered By - user17691074
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.