ios - Quickblox chatroom did receive message is not calling -
i facing problem in not receiving messages while chatting in group type qbchatdialogtypepublicgroup. can see in logs message coming me. per explanation in quickblox official website following method should called when message received
- (void)chatroomdidreceivemessage:(qbchatmessage )message fromdialogid:(nsstring )dialogid - (void)chatdidnotsendmessage:(qbchatmessage )message todialogid:(nsstring )dialogid error:(nserror *)error
but none of above delegate calling.
here steps have taken -
for login:-
[qbrequest loginwithuserlogin:[[appdelegate sharedappdelegate]getqbuserinstance].login password:[[appdelegate sharedappdelegate]getqbuserinstance].password successblock:^(qbresponse response, qbuuser user) { nslog(@"quickblox user id %lu", (unsigned long)user.id); [[nsuserdefaults standarduserdefaults] setvalue:[nsstring stringwithformat:@"%lu", (unsigned long)user.id]forkey:@"quickbloxuserid"]; [[appdelegate sharedappdelegate]getqbuserinstance].id=user.id; // set chat delegate [[qbchat instance] adddelegate:self]; // login chat [[qbchat instance] loginwithuser:[[appdelegate sharedappdelegate]getqbuserinstance]]; } errorblock:^(qbresponse *response) { // error handling nslog(@"error: %@", response.error); }]; -(void) chatdidlogin{ [qbchat instance].keepaliveinterval = 30; [qbchat instance].autoreconnectenabled = yes; [qbchat instance].streammanagementenabled = yes; nslog(@"you have signed in quickblox chat"); [mynetworking endhud]; fmtabbarcontroller *vc = [self.storyboard instantiateviewcontrollerwithidentifier:@"tabview"]; [appdelegate sharedappdelegate].window.rootviewcontroller=vc; //[self presentviewcontroller:vc animated:yes completion:nil]; } - (void)chatdidnotloginwitherror:(nserror *)error{ nslog(@"you have signed in quickblox chat %@", error.domain); nslog(@"you have signed in quickblox chat %@", error.userinfo); nslog(@"you have signed in quickblox chat %@", error.localizeddescription); } - (void)chatdidconnect{ nslog(@"you have signed in quickblox chat"); } - (void)chatdidaccidentallydisconnect{ nslog(@"you have signed in quickblox chat"); } - (void)chatdidreconnect{ nslog(@"you have signed in quickblox chat"); }
to join group, have used following code
groupchatdialog = [[qbchatdialog alloc] initwithdialogid:self.groupchatid type:qbchatdialogtypepublicgroup]; nslog(@"chat dialog %@", [qbchat instance].delegates); // [[qbchat instance] adddelegate:self]; // nslog(@"chat dialog %@", [qbchat instance].delegates); [groupchatdialog setonjoin:^() { [[[uialertview alloc] initwithtitle:@"fm" message:@"group joined successfully" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:@"cancel", nil] show]; }]; [groupchatdialog setonjoinfailed:^(nserror *error) { [[[uialertview alloc] initwithtitle:@"fm" message:error.localizeddescription delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:@"cancel", nil] show]; nslog(@"error %@", error); }]; [groupchatdialog join]; ************************************************************ fetch previous chat have used following code ************************************************************ qbresponsepage *respage = [qbresponsepage responsepagewithlimit:20 skip:0]; [qbrequest messageswithdialogid:self.groupchatid extendedrequest:nil forpage:respage successblock:^(qbresponse response, nsarray messages, qbresponsepage *responcepage) { nslog(@"messages %@", messages); [arraychat addobjectsfromarray:messages]; [self.tableview reloaddata]; } errorblock:^(qbresponse *response) { nslog(@"error: %@", response.error); }];
for sending message, have used following code
messagetosent = [qbchatmessage message]; [messagetosent settext:_textfield.text]; [messagetosent setdatesent:[nsdate date]]; nsmutabledictionary *params = [nsmutabledictionary dictionary]; params[@"save_to_history"] = @yes; [messagetosent setcustomparameters:params]; [groupchatdialog sendmessage:messagetosent]; _textfield.text = @""; [arraychat addobject:messagetosent]; [_tableview reloaddata];
after expect following methods called
- (void)chatroomdidreceivemessage:(qbchatmessage )message fromdialogid:(nsstring )dialogid{ nslog(@"message %@", message); } - (void)chatdidnotsendmessage:(qbchatmessage )message todialogid:(nsstring )dialogid error:(nserror *)error{ [[[uialertview alloc] initwithtitle:@"fm" message:error.localizeddescription delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:@"cancel", nil] show]; nslog(@"error %@", error); }
but not getting called, should called per explanation in website. please let me know missing here or doing wrong here.
the correct method
-(void) chatroomdidreceivemessage:(qbchatmessage *)message fromdialogid:(nsstring *)dialogid
not fromdialogid
Comments
Post a Comment