Javascript Quickblox sigBytes错误-聊天验证
另一个quickblox问题-我在尝试运行应用程序时遇到以下错误:Javascript Quickblox sigBytes错误-聊天验证,javascript,cordova,quickblox,Javascript,Cordova,Quickblox,另一个quickblox问题-我在尝试运行应用程序时遇到以下错误: Uncaught TypeError: Cannot read property 'sigBytes' of undefinedquickblox.js:10707 c.HMAC.i.extend.initquickblox.js:10703 i.Hasher.a.extend._createHmacHelperquickblox.js:101 signMessagequickblox.js:35 createSessionqu
Uncaught TypeError: Cannot read property 'sigBytes' of undefinedquickblox.js:10707 c.HMAC.i.extend.initquickblox.js:10703 i.Hasher.a.extend._createHmacHelperquickblox.js:101 signMessagequickblox.js:35 createSessionquickblox.js:867 QuickBlox.createSessionchat.html:122 (anonymous function)
此错误阻止用户的成功身份验证。正在执行的代码如下(非常不安全-仅用于概念验证!):
要成功登录用户进行聊天,我需要做哪些不同的操作
如果有帮助的话,我之前已经根据他们的“用户”凭证(用户名/密码)为他们生成了一个会话。是否可以简单地重用此会话而不是创建新会话?我突然想到了!(添加一些console.log帮助…)
应用程序正在寻找QBAPP.(etc),从示例中复制后,这些参数的大小写/下划线格式没有对齐,因此“未定义”返回,而sigbytes内容自行消失。因此,请注意其他有此错误的人-在用愚蠢的问题唠叨社区之前,请仔细检查您的代码,了解其大小写和风格
我希望有人能从中吸取教训
var chatToUser = window.localStorage.getItem("chatToUser");
var username = window.localStorage.getItem("user");
var password = window.localStorage.getItem("pwd");
var params = {login:username,password:password};
console.log("PARAMS: ",params);
$(document).ready(function(){
var chatService = new QBChat(params);
});
// JavaScript SDK initialization
QB.init(QBAPP.appID, QBAPP.authKey, QBAPP.authSecret);
// QuickBlox session creation
QB.createSession(params, function(err, result) {
if (err) {
console.log("ERROR:", err.detail);
} else {
chatUser = {
id: result.user_id,
pass: params.password
};
connectChat();
}
});
function connectChat() {
chatService = new QBChat({
onConnectFailed: onConnectFailed,
onConnectSuccess: onConnectSuccess,
onConnectClosed: onConnectClosed,
onChatMessage: onChatMessage
});
console.log("Chat Service: ", chatService);
console.log("Chat User: ", chatuser);
// connect to QB chat service
chatService.connect(chatUser);
}
/* Callbacks
------------------------------------------------------*/
// Connection is failed
function onConnectFailed() {
alert("We're having some difficulty talking to the server. Please try again later, or get in touch if th eproblem persists.")
}
// Connection is success
function onConnectSuccess() {
//green dot - live - status
alert("Connected.")
}
// Connection is closed
function onConnectClosed() {}