使用推送程序发送消息时出现问题

时间:2019-08-28 08:54:41

标签: javascript laravel pusher

我正在使用laravel 5.4并在发送消息时实现实时通知。我有一个活动和一个听众。我的最终目标是在事件被推送时在页面上显示一个JavaScript警报。

<script src="https://js.pusher.com/4.1/pusher.min.js"></script>

<script type="text/javascript">
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;

var pusher = new Pusher('34b9ea6826c359c41c3f', {
    cluster: 'eu',
    encrypted: true
});

var channel = pusher.subscribe('Messages');
channel.bind('msgSend{{$id}}msgReceive{{Auth::user()->id}}', function(data) {
    $('.adsx').append(data.html);
    $("html,body").animate({scrollTop: $('.adsx')[0].scrollHeight}, 0);
});


$('#msgBody').keydown(function (e){
    if(e.keyCode==13 && !e.shiftKey){
        $('#sendMsg').click();
    }
});

我的控制台日志

Pusher : State changed : initialized -> connecting
Pusher : Connecting : {"transport":"ws","url":"wss://ws-eu.pusher.com:443/app/34b9ea6826c359c41c3f?protocol=7&client=js&version=4.1.0&flash=false"}
Pusher : State changed : connecting -> connected with new socket ID 126441.5280355
Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"Messages"}}
Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"Messages"}
 Pusher : No callbacks on Messages for pusher:subscription_succeeded
 Uncaught TypeError: Pusher.ScriptReceivers[1] is not a function at 1?session=NDI2Mjg1OTY

0 个答案:

没有答案