I have tried the sample code provided by QB but event subscription is not working and the method body is never executed. I am attaching my code for reference
subscribeToEvent() async {
try {
await QB.chat.subscribeMessageEvents( QBChatEvents.RECEIVED_NEW_MESSAGE, (data) {
print("dbee inside event subscribeMessageEvents");
Map<String, Object> map = new Map<String, dynamic>.from(data);
String messageType = map["type"];
String messageBody = "system message";
if (messageType == QBChatEvents.RECEIVED_NEW_MESSAGE) {
Map<String, Object> payload =
new Map<String, dynamic>.from(map["payload"]);
messageBody = payload["body"];
String messageId = payload["id"];
print("dbee $messageBody $messageId");
}
}, );
} on Exception catch (e) {
print("Error in subscribing");
print(e);
}
I can see the XMPP logs being printed on console when a new message comes but the subscriber is never invoked.