I'm using the QuickBlox Javascript SDK. This is the code I'm using to send a message to chat room:
var msg = {
type: 'chat',
body: $scope.new_chat_message.msg,
extension: {
save_to_history: 1,
}
};
QB.chat.send(chat_jid,msg);
However, I get a 400 Bad Request when I do this. May I know the correct way to send a message to a chat room?
We recommend you to use the following snippet as an example:
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);
}
}