Quickblox chatRoomDidReceiveMessage没有调用

时间:2016-01-17 19:20:53

标签: ios objective-c quickblox

我遇到的问题是,当我在群组类型QBChatDialogTypeGroup聊天时,我没有收到消息。 我正在使用下面的代码消息发送成功并收到其他组成员的通知但是然后用户在群组聊天视图中无法调用这些方法然后收到消息。

- (void)chatRoomDidReceiveMessage:(QBChatMessage *)message fromRoomJID:(NSString *)roomJID{

}

- (void)chatDidNotSendMessage:(QBChatMessage *)message toRoomJid:(NSString *)roomJid error:(NSError *)error{

}


QBChatDialog *groupChatDialog = qbchatDialog;

[[QBChat instance] delegates];


QBChatMessage *message = [QBChatMessage markableMessage];
[message setText:txt];
[message setDateSent: [NSDate date]];
message.markable =YES;



message.senderNick=[[NSUserDefaults standardUserDefaults] valueForKey:@"name"];

NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"save_to_history"] = @YES;
[message setCustomParameters:params];


[groupChatDialog joinWithCompletionBlock:^(NSError * _Nullable error) {

[privateChatDialog sendMessage:message completionBlock:^(NSError * _Nullable error) {

     }];

1 个答案:

答案 0 :(得分:4)

请使用addDelegate:方法订阅来自聊天的通知:

[[QBChat instance] addDelegate:self];

并实现QBChatDelegate协议方法(可选):

- (void)chatDidReceiveMessage:(QB_NONNULL QBChatMessage *)message;
- (void)chatDidReceiveSystemMessage:(QB_NONNULL QBChatMessage *)message;
- (void)chatRoomDidReceiveMessage:(QB_NONNULL QBChatMessage *)message fromDialogID:(QB_NONNULL NSString *)dialogID;

Create new dialog文档。