chatDidReceiveMessage: not called

2019-09-03 11:19发布

问题:

I use QuickBlox in application with private and group public chats. I've added delegate with QBChat's addDelegate: method, send messages and get incoming messages in delegate's chatDidReceiveMessage: method. While with private chats all is working fine, with public groups chatDidReceiveMessage: not triggered, but I see incoming message in log:

Message RCV: <message xmlns="jabber:client" id="5677e315a28f9a1aa10007df" to="7084298-30903@chat.quickblox.com/7B2CAB4D-1BCE-44EF-B6E4-2B4E8C5D4DF9" type="groupchat" from="30903_5671612da28f9abe16003e94@muc.chat.quickblox.com/7106776"><body>2</body><extraParams xmlns="jabber:client"><date_sent>1450697496.373676</date_sent><dialog_id>5671612da28f9abe16003e94</dialog_id></extraParams><delay xmlns="urn:xmpp:delay" stamp="2015-12-21T11:31:34Z"/></message>

Message sending code for private and public chats is the same:

[QBRequest createMessage:message successBlock:^(QBResponse * _Nonnull response, QBChatMessage * _Nonnull createdMessage) {
    //
     ** success callback here **

    [dialog sendMessage:createdMessage completionBlock:NULL];
    //
} errorBlock:^(QBResponse * _Nonnull response) {
    //
    // ** error callback  here**
}];

Is it a bug or I missed something about messages sending?

回答1:

Ok, got it.

To catch messages, posted to rooms, you must use another delegate's method - chatRoomDidReceiveMessage:fromDialogID:. I was fooled by chatDidReceiveMessage: method's name, since documentation on this one says nothing except "fired when new message was received from QBChat".