Skip to content

onMessageListener not being called #57

@hash1492

Description

@hash1492

I am using quickblox Javascript SDK version 1.15.1 in my cordova app (using Ionic Framework)

There is a chat dialog between users A and B.
User A sends a message to user B, using the code shown below:


$scope.sendMessage = function () {
            var data =  {
                send_to_chat:1,
                message: $scope.message.text,
                recipient_id: recipient_id
            }

            if(dialog_id){
                data.chat_dialog_id = dialog_id;
            }

            $http({method: 'POST', url: 'https://api.quickblox.com/chat/Message.json', headers: {'Content-Type': 'application/json','QB-Token': $rootScope.quickblox_session.token}, data: data})
            .then(function(response) {
                $scope.message.text = "";
                if(!dialog_id){
                    dialog_id = response.data.chat_dialog_id
                }
                getMessagesList();
            },function(err){
                console.log(err);
            })

        }

I have to use the REST API for sending message as the QB.chat.send(opponentId, msg); call throws an error like "Cannot find send of undefined"

Anyways, the message is sent using the REST API call, and it is added to the chat dialog. I think this should trigger the onMessage method that I have given to the onMessageListener

QB.chat.onMessageListener = onMessage

Basically whenever a user receives a message in a dialog, the listener should be called (Correct?). But it is not calling. But when I manually re-fetch the messages of this dialog, I do get the new message in that dialog

So the message is being added to the dialog but my listener is being called when i receive a new message.

Please help me I am stuck on this for a long time! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions