PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 7, 2022

[FIXED] Notification broadcast or event broadcasting in Laravel chat application?

 January 07, 2022     laravel, laravel-8, php     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing