从pusher注销时,广播接收器无法正常工作

问题描述 投票:1回答:1

我确实在推送器的应用程序中实现了广播通知。它是在现场。它工作得很好,但问题是当我从推动器退出或关闭推动器窗口时,无法获得通知。如果我再次登录pusher然后通知工作。

在刀片中:

Echo.channel('NotificationChannel')
  .listen('NotificationEvent', (e) => {
      if( {{Auth::user()->id}} == e.to_doctor_notification.id){
        toastr.success('You have a new patient request.', e.to_doctor_notification.name, {timeOut: 50000, progressBar: true, positionClass: 'toast-bottom-left', closeButton: true, newestOnTop: true, extendedTimeOut: 100000})
      };
  });

在控制器中:

broadcast(new NotificationEvent($to_doctor_notification));

在NotificationEvent中:

public function broadcastOn(){
    return new Channel('NotificationChannel');
}

在bootstrap.js中:

import Echo from "laravel-echo"
window.Pusher = require('pusher-js');
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'app-key',
    cluster: 'ap2',
    encrypted: true
});
laravel firebase-realtime-database push-notification broadcastreceiver pusher
1个回答
0
投票

我解决了这个问题。我有太多的javascript文件包含在内。这就是为什么它不起作用。

我包括推杆链接this is pusher link

这些是通知收到的代码,其中页面想要查看通知。

<script>
      var pusher = new Pusher('app-key', {
      cluster: 'ap2',
      forceTLS: true
     });

var channel = pusher.subscribe('NotificationChannel');
channel.bind('EchoEvent', function(e) {
  if( {{Auth::user()->id}} == e.to_doctor_notification.id){
    toastr.success('You have a new patient request.', e.to_doctor_notification.name, {timeOut: 50000, progressBar: true, positionClass: 'toast-bottom-left', closeButton: true, newestOnTop: true, extendedTimeOut: 100000})
  };
});

© www.soinside.com 2019 - 2024. All rights reserved.