Message body empty on quickblox ios in xamarin native c#
<p>i've translated the quickblox's sample app for Xamarin forms in Xamarin iOS and Android native.
Everything works "except" that the retrieving of the message fails.</p>

<p>I send the message from one client, and the event is catched from the other chat occupant:</p>

<pre><code>XMPP: DispatchEvents ====&gt; &lt;message id="580735ed335fb760ae0017ec" xmlns="jabber:client" from="18029700-46533@chat.quickblox.com/1220770403-quickblox-68179" type="chat" to="18976912-46533@chat.quickblox.com"&gt;&lt;extraParams xmlns="jabber:client"&gt;&lt;save_to_history&gt;1&lt;/save_to_history&gt;&lt;dialog_id&gt;5800aea1a28f9a1c1f000010&lt;/dialog_id&gt;&lt;message_id&gt;580735ed335fb760ae0017ec&lt;/message_id&gt;&lt;date_sent&gt;1476867565&lt;/date_sent&gt;&lt;/extraParams&gt;&lt;body&gt;test+message&lt;/body&gt;&lt;thread&gt;5800aea1a28f9a1c1f000010&lt;/thread&gt;&lt;/message&gt;
XMPP: OnMessageReceived ====&gt;  From: 18029700 To: 18976912 Body:  DateSent 1476867565 FullXmlMessage: &lt;message id="580735ed335fb760ae0017ec" xmlns="jabber:client" from="18029700-46533@chat.quickblox.com/1220770403-quickblox-68179" type="chat" to="18976912-46533@chat.quickblox.com"&gt;&lt;extraParams xmlns="jabber:client"&gt;&lt;save_to_history&gt;1&lt;/save_to_history&gt;&lt;dialog_id&gt;5800aea1a28f9a1c1f000010&lt;/dialog_id&gt;&lt;message_id&gt;580735ed335fb760ae0017ec&lt;/message_id&gt;&lt;date_sent&gt;1476867565&lt;/date_sent&gt;&lt;/extraParams&gt;&lt;body&gt;test+message&lt;/body&gt;&lt;thread&gt;5800aea1a28f9a1c1f000010&lt;/thread&gt;&lt;/message&gt;
</code></pre>

<p>as you can see the Body part into the event OnMessageReceived is empty!
But the html part in the end of this snippet contains the message "test+message"</p>

<p>this is the PrivateChat Class</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using QbChat.Pcl.Repository;
using Quickblox.Sdk.GeneralDataModel.Models;
using Quickblox.Sdk.Modules.ChatXmppModule;
using Quickblox.Sdk.Modules.UsersModule.Models;
using UIKit;
using Xmpp.Im;

namespace KeepInTouch.iOS
{
    public partial class PrivateChat : BaseChat
    {
        PrivateChatManager privateChatManager;

        public PrivateChat(string dialogId, string nibname) : base(dialogId, nibname) { }

        public async override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            AppDelegate.R.NavController.SetNavigationBarHidden(true, true);
            await MessageProvider.Reconnect();
        }

        public override void ViewDidLoad()
        {
            base_tb_chat = tb_chat;
            base_txt_chat = txt_chat;
            base.ViewDidLoad();
            view_top.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("navbar_top_kit.png"));
            tb_chat.TableFooterView = new UIView();
            IsBusyIndicatorVisible = true;
            var dialog = Database.Instance().GetDialog(dialogId);
            var opponentId = dialog.OccupantIds.Split(',').Select(int.Parse).First(id =&gt; id != QbChat.UserId);
            ChatXmppClient xmpc = QbChat.QbProvider.GetXmppClient();
            privateChatManager = xmpc.GetPrivateChatManager(opponentId, dialogId);
            privateChatManager.MessageReceived += OnMessageReceived;
            DialogName = dialog.Name;

            //xmpc.MessageReceived += OnMessageReceived;

            btn_chat.TouchUpInside += async delegate {
                await SendMessageCommandExecute();
                txt_chat.Text = "";
            };

            txt_chat.ShouldReturn += (textField) =&gt; {
                textField.ResignFirstResponder();
                return true;
            };

            txt_chat.EditingChanged += async delegate {
                MessageText = txt_chat.Text;
                await MessageProvider.Reconnect();
            };

            btn_back.TouchUpInside += delegate {
                DismissViewController(false, null);
            };

            IsBusyIndicatorVisible = true;

            Task.Factory.StartNew(async () =&gt; {
                var users = await QbChat.QbProvider.GetUsersByIdsAsync(dialog.OccupantIds);
                var opponentUser = users.FirstOrDefault(u =&gt; u.Id != QbChat.UserId);
                if (opponentUser != null &amp;&amp; opponentUser.BlobId.HasValue) {
                    await QbChat.QbProvider.GetImageAsync(opponentUser.BlobId.Value).ContinueWith((task, result) =&gt; {
                        //var bytes = 
                        task.ConfigureAwait(true).GetAwaiter().GetResult();
                    }, TaskScheduler.FromCurrentSynchronizationContext());
                }
                opponentUsers = new List&lt;User&gt; { opponentUser };
                await LoadMessages();
                InvokeOnMainThread(() =&gt;
                    IsBusyIndicatorVisible = false
                );
            });
        }

        async void OnMessageReceived(object sender, MessageEventArgs messageEventArgs)
        {
            if (messageEventArgs.MessageType == MessageType.Chat ||
                messageEventArgs.MessageType == MessageType.Groupchat) {
                string decodedMessage = System.Net.WebUtility.UrlDecode(messageEventArgs.Message.MessageText);
                var messageTable = new MessageTable();
                messageTable.SenderId = messageEventArgs.Message.SenderId;
                messageTable.DialogId = messageEventArgs.Message.ChatDialogId;
                messageTable.DateSent = messageEventArgs.Message.DateSent;
                if (messageEventArgs.Message.NotificationType != 0) {
                    if (messageEventArgs.Message.NotificationType == NotificationTypes.GroupUpdate) {
                        if (messageEventArgs.Message.AddedOccupantsIds.Any()) {
                            var userIds = new List&lt;int&gt;(messageEventArgs.Message.AddedOccupantsIds);
                            userIds.Add(messageEventArgs.Message.SenderId);
                            var users = await QbChat.QbProvider.GetUsersByIdsAsync(string.Join(",", userIds));
                            var addedUsers = users.Where(u =&gt; u.Id != messageEventArgs.Message.SenderId);
                            var senderUser = users.First(u =&gt; u.Id == messageEventArgs.Message.SenderId);
                            messageTable.Text = senderUser.FullName + " added users: " + string.Join(",", addedUsers.Select(u =&gt; u.FullName));
                        } else if (messageEventArgs.Message.DeletedOccupantsIds.Any()) {
                            var userIds = new List&lt;int&gt;(messageEventArgs.Message.DeletedOccupantsIds);
                            var users = await QbChat.QbProvider.GetUsersByIdsAsync(string.Join(",", userIds));
                            messageTable.Text = string.Join(",", users.Select(u =&gt; u.FullName)) + " left this room";
                        }
                        //var dialogInfo = await QbChat.QbProvider.GetDialogAsync(messageEventArgs.Message.ChatDialogId);
                        //if (dialogInfo == null)
                        //{
                        //    return;
                        //}
                        //var dialog = new DialogTable(dialogInfo);
                        //Database.Instance().SaveDialog(dialog);
                    }
                } else {
                    messageTable.Text = decodedMessage;
                }

                await SetRecepientName(messageTable);

                Messages.Add(messageTable);

                InvokeOnMainThread(async () =&gt; {
                    tb_chat.ReloadData();
                    await ScrollList();
                });
            }
        }

        public async Task LoadMessages()
        {
            List&lt;Message&gt; messages;
            try {
                messages = await QbChat.QbProvider.GetMessagesAsync(dialogId);
            } catch (Exception ex) {
                Console.WriteLine(ex);
                return;
            }

            if (messages != null) {
                messages = messages.OrderBy(message =&gt; message.DateSent).ToList();
                foreach (var message in messages) {
                    var chatMessage = new MessageTable();
                    chatMessage.DateSent = message.DateSent;
                    chatMessage.SenderId = message.SenderId;
                    chatMessage.MessageId = message.Id;
                    if (message.RecipientId.HasValue)
                        chatMessage.RecepientId = message.RecipientId.Value;
                    chatMessage.DialogId = message.ChatDialogId;
                    chatMessage.IsRead = message.Read == 1;
                    await SetRecepientName(chatMessage);
                    chatMessage.Text = System.Net.WebUtility.UrlDecode(message.MessageText);
                    InvokeOnMainThread(() =&gt;
                        Messages.Add(chatMessage)
                    );
                }

                InvokeOnMainThread(async () =&gt; {
                    tb_chat.ReloadData();
                    await ScrollList();
                });
            }
        }

        async Task SendMessageCommandExecute()
        {
            var message = MessageText != null ? MessageText.Trim() : string.Empty;
            if (!string.IsNullOrEmpty(message)) {
                var m = new MessageTable();
                m.SenderId = QbChat.UserId;
                m.Text = message;
                m.DialogId = dialogId;
                m.RecepientFullName = "Me";
                try {
                    await MessageProvider.Reconnect();
                    var encodedMessage = System.Net.WebUtility.UrlEncode(message);
                    privateChatManager.SendMessage(encodedMessage);
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                    return;
                }
                long unixTimestamp = DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks;
                unixTimestamp /= TimeSpan.TicksPerSecond;
                m.DateSent = unixTimestamp;
                m.ID = Database.Instance().SaveMessage(m);
                var dialog = Database.Instance().GetDialog(dialogId);
                dialog.LastMessage = m.Text;
                dialog.LastMessageSent = DateTime.UtcNow;
                Database.Instance().SaveDialog(dialog, true);
                Messages.Add(m);
                MessageText = "";
                InvokeOnMainThread(async () =&gt; {
                    tb_chat.ReloadData();
                    await ScrollList();
                });
            }
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
        }
    }
}
</code></pre>

<p>long story short the sdk receive the message but apparently fail to parse the body message. fire the handler but if empty don't call the privateChatManager.MessageReceived.</p>

<p>could anyone help please?
Thank you</p>