Saturday, March 18, 2017

Using Laravel 5.4 pusher

I am having trouble making pusher work . I have followed the documentation but I donot know the problem is.. The console returns null.

public function broadcastOn()
{

    return new PrivateChannel('my-channel');
}

and here is my js for pusher.

 <script src="https://js.pusher.com/4.0/pusher.min.js"></script>
<script>
(function () {



    // Enable pusher logging - don't include this in production
    Pusher.logToConsole = true;

var pusher = new Pusher('6049410e84e42d918b14', { encrypted: true });

    var channel = pusher.subscribe('my-channel');

    channel.bind('\Dms\Events\NewNotification', addMessage);

    function addMessage(data) {
        var listItem = $("<li class='list-group-item'></li>");
        listItem.html(data.message);
        $('#messages').prepend(listItem);

        console.log(data.message)
    }

})()

Above is all the code that I have used as test. Please anyone who have done this assist. Laravel 5.4 is what am using right now.



via philip Njuguna

Advertisement