2017-10-23 28 views
0

PusherとLaravelエコーをプライベートチャネルで通知したい。PusherとLaravelによるブロードキャスト通知のエコー

マイbootstrap.jsはコンソールそれで

<?php 

namespace App\Providers; 

use Illuminate\Support\Facades\Broadcast; 
use Illuminate\Support\ServiceProvider; 

class BroadcastServiceProvider extends ServiceProvider { 
    /** 
    * Bootstrap any application services. 
    * 
    * @return void 
    */ 
    public function boot() { 

     Broadcast::routes(); 

     Broadcast::channel('App.User.*', function ($user, $userId) { 
      return (int) $user->id === (int) $userId; 
     }); 
    } 
} 

以下のような

<script> 
    export default { 
     mounted() { 
      this.listen() 
     }, 
     props: ['id'], 
     methods: { 
      listen() { 
       Echo.private('App.User.' + this.id) 
        .notification((notification) => { 
         alert('new notification') 
        }) 
       } 
     } 
    } 
</script> 

私BroadcastServiceProvider.php以下のように

import Echo from 'laravel-echo' 

window.Pusher = require('pusher-js'); 

window.Echo = new Echo({ 
    broadcaster: 'pusher', 
    key: '5c3621c15520b7e2fb02', 
    cluster: 'ap2' 
}); 

Pusher.log = function(message){ 

    window.console.log(message) 
} 

と私のnotification.vueファイル下記のようなファイル以下のようなエラーが表示されます

Pusher : State changed : connecting -> connected with new socket ID 334.3086157 
Pusher : No callbacks on private-App.User.1 for pusher:subscription_error 
if I changed BROADCAST_DRIVER=driver 

それは

Pusher : State changed : connecting -> connected with new socket ID 
Pusher : No callbacks on private-App.User.1 for pusher:subscription_error 

私はこれをどのように修正することができ、以下のようなエラーを与えますか?

答えて

0

コードベース全体を見ることなく、どこに問題があるのか​​を正確に知ることは難しいですが、Pusherのブログで過去に私が働いていたプロセス全体を紹介するブログ記事をお勧めします。

https://blog.pusher.com/how-to-build-a-laravel-chat-app-with-pusher/

うまくいけば、それが役立ちます!

+0

どのコードを見たいのですか? –

関連する問題