无法使用 QuickBlox Javascript SDK 发送聊天消息
Can't send chat message using QuickBlox Javascript SDK
我正在使用 QuickBlox Javascript SDK。这是我用来向聊天室发送消息的代码:
var msg = {
type: 'chat',
body: $scope.new_chat_message.msg,
extension: {
save_to_history: 1,
}
};
QB.chat.send(chat_jid,msg);
但是,我在执行此操作时收到 400 Bad Request。我可以知道向聊天室发送消息的正确方法吗?
我们建议您使用以下代码段作为示例:
function sendMessage(text, attachmentFileId) {
var msg = {
type: currentDialog.type == 3 ? 'chat' : 'groupchat',
body: text,
extension: {
save_to_history: 1,
},
senderId: currentUser.id,
};
if (currentDialog.type == 3) {
opponentId = QB.chat.helpers.getRecipientId(currentDialog.occupants_ids, currentUser.id);
QB.chat.send(opponentId, msg);
} else {
QB.chat.send(currentDialog.xmpp_room_jid, msg);
}
}
我正在使用 QuickBlox Javascript SDK。这是我用来向聊天室发送消息的代码:
var msg = {
type: 'chat',
body: $scope.new_chat_message.msg,
extension: {
save_to_history: 1,
}
};
QB.chat.send(chat_jid,msg);
但是,我在执行此操作时收到 400 Bad Request。我可以知道向聊天室发送消息的正确方法吗?
我们建议您使用以下代码段作为示例:
function sendMessage(text, attachmentFileId) {
var msg = {
type: currentDialog.type == 3 ? 'chat' : 'groupchat',
body: text,
extension: {
save_to_history: 1,
},
senderId: currentUser.id,
};
if (currentDialog.type == 3) {
opponentId = QB.chat.helpers.getRecipientId(currentDialog.occupants_ids, currentUser.id);
QB.chat.send(opponentId, msg);
} else {
QB.chat.send(currentDialog.xmpp_room_jid, msg);
}
}