1

I followed the instruction from this link to create a web push using pusher: https://blog.pusher.com/create-web-notifications-using-laravel-pusher/

But when i tried to fire my event, i cant see any event catch in my pusher dashboard debug console.

Here is the screenshot of my test

Image preview

Here are some code

route/web.php :

Route::get('/eventtest', function () {
    event(new App\Events\StatusChanged('someone'));
    return "Event has been sent!";
});

event class :

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class StatusChanged implements ShouldBroadcast
{
    use InteractsWithSockets, SerializesModels;

    public $message;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        // return new PrivateChannel('statusChanged');
        return ['status-changed'];
    }
}

broadcasting config :

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_KEY'),
            'secret' => env('PUSHER_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => 'ap1',
                'encrypted' => true
            ],
        ],
6
  • Have you specified pusher as broadcast driver in your .env file? If yes, then check the region of your app cluster in pusher matches to 'ap1' Nov 3, 2017 at 9:42
  • @PawanKumar i already set the env file and my app cluster is set to ap1 while i created it Nov 4, 2017 at 2:27
  • Okay, did you uncomment App\Providers\BroadcastServiceProvider::class, in config/app.php ? Nov 4, 2017 at 3:10
  • @PawanKumar yup, i already uncommented it. Nov 6, 2017 at 3:07
  • Okay, Please check your App cluster region. Try creating an App in EU region and see if it works. Also change the cluster to 'eu' in broadcast.php. Nov 6, 2017 at 3:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.