Git Product home page Git Product logo

laravel-pusher-web-notifications's Introduction

How to use Laravel and Pusher to create web notifications

Get help on Codementor

This is an example of how to create web notifications. You can read the article on Pusher here

Getting Started

  • Download or clone the project
  • Rename .env.example to .env
  • Run composer install to install the dependencies
  • Open resources/views/welcome.blade.php and update the Pusher keys
  • Update the PUSHER_APP_* keys in the .env file
  • Change the BROADCAST_DRIVER to pusher
  • Run the command: php artisan serve to start the app

Built With

  • Laravel framework
  • PHP

laravel-pusher-web-notifications's People

Contributors

neoighodaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

laravel-pusher-web-notifications's Issues

Your Code is not working for me.

I have just cloned your project setup all the pusher configurations but the notification is not send. The notification bell is also not displaying.

Pusher

the event return empty array ?

command line error

when i typed php artisan serve the command line reply with

PHP Warning: require(C:\xampp\htdocs\laravel-pusher-web-notifications-master\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravel-pusher-web-notifications-master\bootstrap\autoload.php on line 17

Installation error.

Please kindly add composer install command to the first step of set up instruction and local installation just for the sake of beginners.

Pusher

It's not working, the data array returns empty. When '/test' route is hit no push notification is received at the other end. Somethings missing in the code I guess.

Event Action Messages not delivering.

When the /test route is been clicked the necessary navbar notification isn't popping up on the other browser tab. You may need to use laravel Echo to fix or npm to require pusher it self.

array_merge(): Argument #2 is not an array in Pusher.php

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.