user6500031
user6500031

Reputation:

Creating Dialog issue in private Chat with Quickblox

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?

Upvotes: 0

Views: 962

Answers (3)

Hardik Bar
Hardik Bar

Reputation: 1760

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

Upvotes: 0

komal
komal

Reputation: 1

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.

Upvotes: 0

Andrey Ivanov
Andrey Ivanov

Reputation: 190

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

Upvotes: 0

Related Questions