ios - Multiple dialogs are created when chatting Quickblox -
while creating chat dialog group. e.g user creating dialog , user b want use dialog. scenario occurring user create 1 dialog , user b create dialog. not able chat each other because of 2 different dialogs. below code using create dialog :-
-(void) movetochatview:(qbchatdialog *)chatdialog objfriend:(friend *)objfriend { [qbrequest createdialog:chatdialog successblock:^(qbresponse *response, qbchatdialog *createddialog) { // success, } errorblock:^(qbresponse *response) { }]; }
edit :- there method createorjoinroomwithname??
to if want add user in groupchat need update group dialogue.
qbchatdialog *updatedialog = [[qbchatdialog alloc] initwithdialogid:@"53aac645535c12bd3b008a40" type:qbchatdialogtypegroup]; updatedialog.pushoccupantsids = @[@"300", @"301", @"302"]; updatedialog.name = @"school friends"; [qbrequest updatedialog:updatedialog successblock:^(qbresponse *responce, qbchatdialog *dialog) { } errorblock:^(qbresponse *response) { }];
for more detail check update_group_dialog
and chat in group dialogue check chat_in_group_dialog
don't forget use delegate method.
pragma mark qbchatdelegate
- (void)chatroomdidreceivemessage:(qbchatmessage *)message fromdialogid:(nsstring *)dialogid{ }
edit 1:- dialogid retriving dialog.
qbresponsepage *page = [qbresponsepage responsepagewithlimit:100 skip:0]; [qbrequest dialogsforpage:page extendedrequest:nil successblock:^(qbresponse *response, nsarray *dialogobjects, nsset *dialogsusersids, qbresponsepage *page) { } errorblock:^(qbresponse *response) { }];
edit 2:- know dialogid when creating new dialog use createchatnotificationforgroupchatcreation method.
- (qbchatmessage *)createchatnotificationforgroupchatcreation:(qbdialog *)dialog { // create message: qbchatmessage *invitemessage = [qbchatmessage message]; nsmutabledictionary *customparams = [nsmutabledictionary new]; customparams[@"xmpp_room_jid"] = dialog.roomjid; customparams[@"name"] = dialog.name; customparams[@"_id"] = dialog.id; customparams[@"type"] = @(dialog.type); customparams[@"occupants_ids"] = [dialog.occupantids componentsjoinedbystring:@","]; // add notification_type=1 params when created group chat // customparams[@"notification_type"] = @"1"; invitemessage.customparameters = customparams; return invitemessage; }
Comments
Post a Comment