- (void)chatDidReceiveMessage:(QBChatMessage *)message not working

≡放荡痞女 提交于 2019-12-05 18:51:55

You are not sending message, but creating it in the REST. So QBChat delegate 'chatDidReceiveMessage' will not be called. It is still valid thing to do, however to receive such message you need to download it from REST (e.g. '[QBRequest messagesForDialogID:completionBlock:errorBlock:]' ).

In order to receive messages through delegate you need to use 'sendMessage:completion:' of QBChatDialog, which is using XMPP to send and receive messages. In your situation you should do this:

QBChatMessage *message =[QBChatMessage message];
[message setText:self.messageText.text];

params[@"messageStatus"]=@"Test Message";
params[@"save_to_history"] = @YES;

[message setCustomParameters:params];

[message setRecipientID:[[[NSUserDefaults standardUserDefaults] objectForKey:PARTNERID] integerValue]];

[chatDialog sendMessage:message completionBlock:^(NSError * _Nullable error) {
    if (error != nil) {
        NSLog(@"Failed to send message with error: %@", error);
    }
}];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!