1
我使用PHP推送庫(angularjs)與PHP後端。推送解除綁定不起作用
JS:
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('API_KEY', {
cluster: 'ap2',
encrypted: true
});
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function (data) {
common.flashMsg('success', data.message);
});
的綁定和取消綁定代碼:
$scope.workerStatus = function (status) {
if (status == 'available') {
common.flashMsg('success', "Welcome Again...!");
channel.bind('my-event', function (data) {
common.flashMsg('success', data.message);
});
} else {
common.flashMsg("error", "You're now offline. Good Bye.");
channel.unbind('my-event', function() {
common.flashMsg('success', data.message);
});
}
}
我想取消綁定channel
,當用戶註銷,並停止通知,但渠道unbind
事件不能正常工作,用戶仍能夠收到通知。 我錯過了什麼?
我經過的引用,不同的功能,因此呼叫失敗,現在問題同樣的功能解決了第二個參數'unbind' –