【问题标题】:Can't send chat message using QuickBlox Javascript SDK无法使用 QuickBlox Javascript SDK 发送聊天消息
【发布时间】:2015-07-15 10:14:56
【问题描述】:

我正在使用 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。我可以知道向聊天室发送消息的正确方法吗?

【问题讨论】:

    标签: javascript xmpp quickblox


    【解决方案1】:

    我们建议您使用以下 sn-p 作为示例:

    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);
      }
    }
    

    【讨论】:

    • 我有同样的问题,但我得到一个 403“发送群聊消息的权限不足”。知道如何解决这个问题吗?我使用了与上面相同的代码,但对话框类型为 2
    猜你喜欢
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多