Using Xamarin, I installed the QuickBlox Nuget (1.2.7): https://www.nuget.org/packages/Quickblox.Sdk/
and using this tutorial: http://quickblox.com/developers/Sample-chat-xamarin this tutorial is probably out of date, as some of the code snippets do not work out of the box and some changes to classes names and functions needs to be done, but it's the best source I could find for Xamarin and QuicBlox.
I'm trying to send and receive messages and having some difficulties. While I can send messages successfully and see them in the chat history using the admin panel, i couldn't find a way to receive them with the message text.
The message received with message id, sender id etc, but the messageText field is always null. When I use getMessagesAsync to actively get the message (by its id or as part of the chat dialog history) i get a message with text. So the text is there, the event get called but the text stays null...
I tried different ways of sending and receiving messages, using:
Send Messages - both worked, the message was sent and can be seen using the admin panel:
1.
quickbloxClient.ChatXmppClient.SendMessage(...)
2.
privateChatManager.SendMessage (messageText);
Receive Messages - only the ChatXmppClient worked, the message received with all its details but the message text field is null:
1.
quickbloxClient.ChatXmppClient.MessageReceived += MessageReceived;
public async void MessageReceived (object sender, MessageEventArgs messageEventArgs)
{
if (messageEventArgs.MessageType == Xmpp.Im.MessageType.Chat && messageEventArgs.Message != null)
{
var message = messageEventArgs.Message; // contains message's details
var text = messageEventArgs.Message.messageText; // null
}
}
/// received (the event fired) with message details but without message text (null)
2.
privateChatManager.MessageReceived += MessageReceived;
/// the event doesn't get called
Any help would be appreciated.
Workaround code: Sending -
Receiving -
I know I am late to answer, but hope it might help somebody else. I was facing similar issue with my application. After a lot of efforts I came to know that there was something wrong with Quickblox Nuget I was using, which was 1.2.7. I downgraded it to 1.2.2 in all projects (ie, PCL, droid and ios) then rebuilt my project and bingo! It worked.