我正在尝试与QuickBlox实施私密的1对1聊天,但是在http://quickblox.com/developers/Chat#Create_dialog之后仅按照Quickblox文档显示群聊。当我尝试仅发送单个occupants_ids时,会出现以下错误:
{
"errors": [
"Occupants_ids cannot be less than one."
]
}
我正在使用以下正文创建Dialog API:
{
"type": 3,
"name": "",
"occupant_id": "13822296"
}
我是否需要更新请求正文中的某些密钥?
答案 0 :(得分:1)
请检查:Create new 1-1(private) chat dialog
来自documentaton的代码为我工作:
let chatDialog: QBChatDialog = QBChatDialog(dialogID: nil, type: QBChatDialogType.Private)
chatDialog.occupantIDs = [user.ID]
QBRequest.createDialog(chatDialog, successBlock: {(response: QBResponse?, createdDialog: QBChatDialog?) in completion?(response: response, createdDialog: chatDialog)
print("sucess + \(response)")
}, errorBlock: {(response: QBResponse!) in
print("response + \(response)")
})
答案 1 :(得分:0)
QBChatDialog *chatDialog = [[QBChatDialog alloc] initWithDialogID:null type:QBChatDialogTypePrivate];
chatDialog.occupantIDs = @[@(1530190)];
[QBRequest createDialog:chatDialog successBlock:^(QBResponse *response, QBChatDialog *createdDialog) {
} errorBlock:^(QBResponse *response) {
}];
你可以使用它,你应该提供一个occupantIds。如果有效,请告诉我。
答案 2 :(得分:0)
let user = QBUUser()
user.id = UInt(arrDoctors[sender.tag].QuickBloxId)!
user.fullName = arrDoctors[sender.tag].title.capitalizeFirst
ServicesManager.instance().chatService.createPrivateChatDialog(withOpponent: user) { (response, dialog) in
let chatvc = CHAT_STORYBOARD.instantiateViewController(withIdentifier: "ChatViewController") as! ChatViewController
chatvc.dialog = dialog
self.navigationController?.pushViewController(chatvc, animated: true)
}