Laravel 广播接收机没有';从推送器注销时无法工作
我确实用pusher在应用程序中实现了广播通知。现场直播。它工作得很好,但问题是当我从pusher注销或关闭pusher窗口时,用户无法收到通知。如果我再次登录到pusher,那么通知将起作用 在刀片中:Laravel 广播接收机没有';从推送器注销时无法工作,laravel,firebase-realtime-database,push-notification,broadcastreceiver,pusher,Laravel,Firebase Realtime Database,Push Notification,Broadcastreceiver,Pusher,我确实用pusher在应用程序中实现了广播通知。现场直播。它工作得很好,但问题是当我从pusher注销或关闭pusher窗口时,用户无法收到通知。如果我再次登录到pusher,那么通知将起作用 在刀片中: Echo.channel('NotificationChannel') .listen('NotificationEvent', (e) => { if( {{Auth::user()->id}} == e.to_doctor_notification.id){
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));
在通知事件中:
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
});
我解决了这个问题。我包含了太多的javascript文件。这就是它不起作用的原因 我包括推进器链接 这些是页面希望看到通知的通知接收代码
<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})
};
});
var推进器=新推进器('app-key'{
群集:“ap2”,
forceTLS:对
});
var channel=pusher.subscribe('NotificationChannel');
channel.bind('echeavent',函数(e){
if({Auth::user()->id}}==e.to_doctor_notification.id){
toastr.success('您有一个新的患者请求',e.to_doctor_notification.name,{timeOut:50000,progressBar:true,positionClass:'toast bottom left',closeButton:true,newestOnTop:true,extendedTimeOut:100000})
};
});
我解决了这个问题。我包含了太多的javascript文件。这就是它不起作用的原因 我包括推进器链接 这些是页面希望看到通知的通知接收代码
<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})
};
});
var推进器=新推进器('app-key'{
群集:“ap2”,
forceTLS:对
});
var channel=pusher.subscribe('NotificationChannel');
channel.bind('echeavent',函数(e){
if({Auth::user()->id}}==e.to_doctor_notification.id){
toastr.success('您有一个新的患者请求',e.to_doctor_notification.name,{timeOut:50000,progressBar:true,positionClass:'toast bottom left',closeButton:true,newestOnTop:true,extendedTimeOut:100000})
};
});