Hi ! How are you ? I post my code.
.env file
PUSHER_APP_ID=## BROADCAST_DRIVER=pusher PUSHER_APP_ID=### PUSHER_APP_KEY=## PUSHER_APP_SECRET=
Event file
`class MessageToProveedor implements ShouldBroadcast{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $username;
public $message;
public function __construct($username)
{
$this->username = $username;
$this->message = "liked your status";
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
//channel
return ['my-channel'];
}
public function broadcastAs()
{
//event
return 'my-event';
}
}`
JS File
`<script src="//js.pusher.com/3.1/pusher.min.js"></script>
<script>
var pusher = new Pusher('###', {
cluster: 'us2',
encrypted: true
});
Pusher.logToConsole = true;
// Subscribe to the channel we specified in our Laravel Event
var channel = pusher.subscribe('my-channel');
console.log(channel);
channel.bind('my-event', function(data) {
alert(data);
});
</script>`
**web.php (route) send message**
Route::get('push', function () { event(new App\Events\MessageToProveedor("ssa")); return "Event has been sent!"; })->name('push');
The error is on title. I don´t find any solution.
My log console:
Pusher : State changed : connecting -> connected with new socket ID ## pusher.min.js:8 Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"my-channel"}} pusher.min.js:8 Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"my-channel"} pusher.min.js:8 Pusher : No callbacks on my-channel for pusher:subscription_succeeded