0

I am trying to implement private 1 to 1 chat with QuickBlox but following the Quickblox docs only shows for group chat in http://quickblox.com/developers/Chat#Create_dialog . When I try sending just single occupants_ids, it gives following error :

{
"errors": [
"Occupants_ids cannot be less than one."
]
}

I am hitting create Dialog API with following body :

{
"type": 3,
"name": "",
"occupant_id": "13822296"
}

Do I need to update some keys in my request body?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135

3 Answers3

0

Please check: Create new 1-1(private) chat dialog

Code from documentaton work for me:

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)")
})
Andrey Ivanov
  • 190
  • 1
  • 8
  • Thats correct but its not in swift. Also, Is creating new dialog for 1-1 private chat NOT possible through "Create Dialog API Request" in https://quickblox.com/developers/Chat#Create_dialog? –  Jun 30 '16 at 06:37
0
QBChatDialog *chatDialog = [[QBChatDialog alloc] initWithDialogID:null type:QBChatDialogTypePrivate];
chatDialog.occupantIDs = @[@(1530190)];

[QBRequest createDialog:chatDialog successBlock:^(QBResponse *response, QBChatDialog *createdDialog) {

} errorBlock:^(QBResponse *response) {

}];

you can use this and you should provide one occupantIds. If it works please let me know.

Sushil Sharma
  • 2,321
  • 3
  • 29
  • 49
komal
  • 1
  • 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)
        }
Hardik Bar
  • 1,660
  • 18
  • 27