如何解决Laravel通知在推送器上广播
需要有关推送器广播的通知的帮助。
在控制台中获取这些错误。
pusher.min.js:8 POST http://127.0.0.1:8000/pusher/auth 404(未找到)
pusher.min.js:8 Pusher:无法从您的Web应用获取身份验证信息:404
pusher.min.js:8 Pusher:private-App.User.2上没有用于pusher:subscription_error的回调
我需要回声或其他任何方式来订阅pusher专用频道的帮助
这是我的new-comment.js
var commentNotificationsWrapper = $('.dropdown-comment');
var commentNotificationsToggle = commentNotificationsWrapper.find('a[data-toggle]');
var commentNotificationsCountElem = commentNotificationsToggle.find('i[comment-data-count]');
var commentNotificationsCount = parseInt(commentNotificationsCountElem.data('comment-count'));
var commentNotifications = commentNotificationsWrapper.find('ul.dropdown-menu');
if (commentNotificationsCount <= 0) {
// commentNotificationsWrapper.hide();
}
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher("5f53220af298e18653c8",{
cluster: 'ap2',encrypted: true,auth: {
headers: {
'X-CSRF-Token': '{{ csrf_token() }}'
}
}
});
// Subscribe to the channel we specified in our Laravel Event
var channel = pusher.subscribe('private-App.User.'+userId);
// Bind a function to a Event (the full Laravel class)
channel.bind('Illuminate\\Notifications\\Events\\BroadcastNotificationCreated',function(data) {
var commentExistingNotifications = commentNotifications.html();
var commentNewNotificationHtml = `
<li class="notification active px-3">
<div class="media">
<div class="media-body">
<strong class="notification-title">`+data.message+`</strong>
<!--p class="notification-desc">Extra description can go here</p-->
<div class="notification-meta">
<small class="timestamp">about a minute ago</small>
</div>
</div>
</div>
</li>
`;
commentnotifications.html(commentNewNotificationHtml + commentExistingNotifications);
commentNotificationsCount += 1;
commentNotificationsCountElem.attr('comment-data-count',commentNotificationsCount);
commentNotificationsWrapper.find('.comment-count').text(commentNotificationsCount);
commentNotificationsWrapper.show();
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。