我的通知 RealtimeNotification.php 有:
public function via($notifiable)
{
return ['broadcast'];
}
public function toBroadcast($notifiable){
return new BroadcastMessage([
'name' => 'John Snow'
]);
}
在我看来,我有一个与我的推送帐户连接的推送对象:
var channel = pusher.subscribe('private-App.User.1');
channel.bind('App\\Notifications\\RealtimeNotification', function(data) {
console.log(data);
});
所以,如果我像这样使用,Pusher 在控制台中给我这个错误,也许因为它是一个私有(private) channel ,我没有为 Pusher 配置任何身份验证
Failed to load resource: the server responded with a status of 404 (Not Found)
Pusher : Couldn't get auth info from your webapp : 404
我的问题是,如何广播到公共(public) channel ?
在 Laravel 5.4 文档中,说道: “通知将在使用 {notABLE}.{id} 约定格式化的私有(private) channel 上广播。”
我认为应该有一个方法,但我仍然找不到它,欢迎任何帮助。
最佳答案
channel 应该是 Channel、PrivateChannel 或 PresenceChannel 的实例。 Channel 的实例代表任何用户都可以订阅的公共(public) channel ,而 PrivateChannels 和 PresenceChannels 代表需要 channel 授权的私有(private) channel ......如 laravel 官方文档中所述
关于php - 使用 Laravel 5.4 和推送器向公共(public) channel 广播通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42293081/