public async Task ShowNotifitionAlert(LogisticsNotification logisticsNotification)
        {
            if (Shared.IsLoggedIn)
            {
                if (!ContainNotification(logisticsNotification))
                {
                    LogisticsNotifications.Add(logisticsNotification);
                    var mainPage = Xamarin.Forms.Application.Current != null ? Xamarin.Forms.Application.Current.MainPage : null;
                    if (mainPage == null || mainPage.Navigation == null)
                    {
                        await Task.Run(() =>
                        {
                            while (mainPage == null || mainPage.Navigation == null)
                            {
                                new System.Threading.ManualResetEvent(false).WaitOne(50);
                                mainPage = Xamarin.Forms.Application.Current != null ? Xamarin.Forms.Application.Current.MainPage : null;
                            }
                        });
                    }

                    var lastPape = mainPage;
                    if (mainPage is MasterDetailPage)
                    {
                        lastPape = (mainPage as MasterDetailPage).Detail;
                    }

                    if (lastPape != null && logisticsNotification != null)
                    {
                        try
                        {
                            if (logisticsNotification.IDs != null &&
                                logisticsNotification.Kind != NotificationKind.OrderPlaced &&
                                logisticsNotification.IDs.Count > 0)
                            {
                                string message = (Device.RuntimePlatform == Device.iOS ? "\n" : "") + logisticsNotification.Message;
                                var    view    = await lastPape.DisplayAlert(AppResources.OrderStatus, message, AppResources.View, AppResources.OK);

                                if (view)
                                {
                                    /*var serviceRequestDetailsPage = new ServiceRequestDetailsPage(logisticsNotification.IDs.FirstOrDefault());
                                     * await lastPape.Navigation.PushAsync(serviceRequestDetailsPage);*/
                                }
                            }
                            LogisticsNotifications.Remove(logisticsNotification);
                        }
                        catch (Exception)
                        {
                            LogisticsNotifications.Remove(logisticsNotification);
                            await ShowNotifitionAlert(logisticsNotification);
                        }
                    }
                    else
                    {
                        LogisticsNotifications.Remove(logisticsNotification);
                    }
                }
            }
        }
 public void ShowNotificationAlert(LogisticsNotification logisticsNotification)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         try
         {
             await appServices.ShowNotifitionAlert(logisticsNotification);
         }
         catch (Exception e)
         {
             ExceptionHandler.Catch(e);
             this.IsNeedRefresh         = true;
             this.LogisticsNotification = logisticsNotification;
         }
     });
 }
        public App(LogisticsNotification logisticsNotification = null) : this()
        {
            if (Shared.IsLoggedIn)
            {
                Shared.LocalAddress          = null;
                Application.Current.MainPage = new HomePage();
            }
            else
            {
                Shared.LocalAddress = null;
                var mainPage = new SigninPage();
                Application.Current.MainPage = mainPage;
            }

            MainPage.SetValue(NavigationPage.BarTextColorProperty, Color.White);
            MainPage.SetValue(NavigationPage.BackButtonTitleProperty, AppResources.Back);
        }
        //private static Dictionary<LogisticsNotification, IDisposable> UserDialogConfirms = new Dictionary<LogisticsNotification, IDisposable>();

        private bool ContainNotification(LogisticsNotification logisticsNotification)
        {
            return(LogisticsNotifications.FirstOrDefault((arg) => arg.Kind == logisticsNotification.Kind &&
                                                         (arg.IDs.Count() == logisticsNotification.IDs.Count()) &&
                                                         !arg.IDs.Except(logisticsNotification.IDs).Any()) != null);
        }