private static Task HandlePollNotificationAsync(ServerNotification notification)
        {
            var poll = notification.Data["customData"].ToObject<Poll>();

            if (DonkyCore.Instance.GetService<IAppState>().IsOpen)
            {
                Device.BeginInvokeOnMainThread(async () =>
                {
                    var selectedOption = await Application.Current.MainPage.DisplayActionSheet(poll.Title, null, null, poll.Options);
                    var result = new ContentNotification()
                        .ForUsers("pollresults")
                        .WithCustomContent("Vote", new
                        {
                            pollId = poll.Id,
                            option = selectedOption
                        });
                    await DonkyCore.Instance.NotificationController.SendContentNotificationsAsync(result);
                });
            }
            else
            {
                // TODO: Persist poll for next time app is opened
            }

            return Task.FromResult(0);
        }
        public SendPageViewModel()
        {
            // This is a Xamarin Forms messaging pub/sub
            MessagingCenter.Subscribe<RandomCustomMessageNotificationViewModel>(this, "RandomCustomMessageStructure", (vm) =>
            {
                Debug.WriteLine("Received RandomCustomMessageStructure values:");
                Debug.WriteLine("   customId: " + vm.customId);
                Debug.WriteLine("   from: " + vm.from);
                Debug.WriteLine("   to: " + vm.to);
                Debug.WriteLine("   message: " + vm.message);
                this.ReceivedMessages.Insert(0, vm);
            });

            SendCommand = new Command<string>((key) =>
            {
                if (string.IsNullOrEmpty(Username)) return;

                Task.Run(() =>
                {
                    Debug.WriteLine("Send button pressed in Send Page");

                    var notification = new ContentNotification()
                    .ForUsers(Username.Trim())
                    .WithCustomContent("RandomCustomMessageStructure", new
                    {
                        customId = Guid.NewGuid().ToString(),
                        to = Username.Trim(),
                        from = "iosuser",
                        message = SendMessage.Trim()
                    });

                    try
                    {
                        DonkyCore.Instance.NotificationController.SendContentNotificationsAsync(notification)
                            .ExecuteSynchronously();
                        Debug.WriteLine("SendContentNotificationsAsync completed.");
                    }
                    catch (Exception ex)
                    {

                    }

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        this.Username = string.Empty;
                        this.SendMessage = string.Empty;
                    });


                    Debug.WriteLine("Send handler completed.");

                });
            });

            InitialiseAsync().ExecuteInBackground();
        }