2

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?

Honoo
  • 25
  • 3

1 Answers1

0

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);
  }
}
Sabina Bashuk
  • 189
  • 1
  • 6
  • i have the same problem but i get a 403 "Insufficient privileges to send groupchat message". Any idea how to solve this ? i used the same code than above, but with dialogs of type 2 – Sebastien H. May 12 '17 at 12:37