对象不是参考 - phonegap 中的 Quickblox 聊天

Object not a reference - Quickblox chat in phonegap

我在 phonegap (javascript) 上使用 quickblox 聊天时遇到问题。我使用显示模块模式来显示而不是 'require',这是损坏的代码:

var chatParams = {
            onConnectFailed: onConnectFailed,
            onConnectSuccess: onConnectSuccess,
            onConnectClosed: onConnectClosed,
            onChatMessage: onChatMessage
        };

        QB.createSession(params, function(err, result) {
            if (err==null) {
                chatUser = {
                    id: result.user_id,
                    pass: params.password
                };
                connectChat(chatParams);
            }
            else {
                alert("Something went wrong, please try again later or contact us at contact@domain.co.uk if the problem persists.");
            }
        });

        function connectChat(chatParams) {
            //This line here:
            var chatService = new QBChat(chatParams);
            console.log(chatService);
            // connect to QB chat service
            chatService.connect(chatUser);
        };

我在突出显示的行收到错误 'object not a reference'。

请指教!

尝试使用此代码作为示例加入聊天:

 QB.chat.connect({userId: user.id, password: user.pass}, function(err, roster) {
    if (err) {
      console.log(err);
    } else {
      console.log(roster);
    }
  });

而不是

  function connectChat(chatParams) {
        //This line here:
        var chatService = new QBChat(chatParams);
        console.log(chatService);
        // connect to QB chat service
        chatService.connect(chatUser);
    };