我遇到的问题是,当我在群组类型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) {
}];
答案 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;