Quickblox chatRoomDidReceiveMessage 没有调用
Posted
技术标签:
【中文标题】Quickblox chatRoomDidReceiveMessage 没有调用【英文标题】:Quickblox chatRoomDidReceiveMessage is not calling 【发布时间】:2016-01-17 19:20:53 【问题描述】:我遇到了一个问题,我在群组类型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】:请使用 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 文档。
【讨论】:
是的,我已经在使用 [[QBChat instance] addDelegate:self];在视图didload - (void)chatDidReceiveMessage:(QB_NONNULL QBChatMessage *)message;此方法在私人聊天中完美调用但在群聊中以下方法不调用 - (void)chatDidReceiveMessage:(QB_NONNULL QBChatMessage *)message; 你试过了吗..? - (void)chatRoomDidReceiveMessage:(QB_NONNULL QBChatMessage)message fromDialogID:(QB_NONNULL NSString)dialogID; 请检查:quickblox.com/developers/… 请注意:chatDialog.occupantIDs - 必填字段 @ManojAher 为了从群聊对话框发送和接收消息,您需要先加入他们。见quickblox.com/developers/…以上是关于Quickblox chatRoomDidReceiveMessage 没有调用的主要内容,如果未能解决你的问题,请参考以下文章
QBRoomChatManager 类在以后的 Quickblox 库中不存在 - quickblox-sdk-release-2