window.JMessage.removeReceiveMessageListener(removeListener) 移除不了

wyd1332806181
2018-12-04 06:39 487 0

ionic1,在进入页面时执行window.JMessage.addReceiveMessageListener(listener)事件监听消息,退出该页面时移除无效,下面是代码

$scope.$on('$ionicView.beforeLeave',function(){
                    alert("该页面注销了")
                    var removeListener = function (msg) {
                        alert("该页面注销了121")
                        alert("移除收到聊天消息"+JSON.stringify(msg))
                    }
                    window.JMessage.removeReceiveMessageListener(removeListener)

                    // window.JMessage.exitConversation({ type: 'single', username: $scope.chatId },
                    // function(success){
                    //     alert('退出聊天会话成功' + JSON.stringify(success))
                    // },function(error){
                    //     alert('退出聊天会话失败' + JSON.stringify(error))
                    // })
                    // window.JMessage.removeReceiveMessageListener(function(msg){
                    //     alert("收到聊天消息删除"+JSON.stringify(msg))
                    // })
})

1个回答

热门排序