我正在使用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错误的请求。我可以知道将消息发送到聊天室的正确方法吗?
我们建议您使用以下代码段作为示例:
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);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句