private async void InitAsync() { try { UserDialogs.Instance.ShowLoading(null, MaskType.None); HttpClient client = new HttpClient(); if (!string.IsNullOrEmpty(Settings.Token)) { string _ContentType = "application/json"; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(_ContentType)); client.DefaultRequestHeaders.Add("Authorization", $"Token {Settings.Token}"); } client.Timeout = TimeSpan.FromMinutes(5); try { var result = await client.GetAsync(Links.QrCodeValidation); if ((int)result.StatusCode == 200) { var jsonString = result.Content.ReadAsStringAsync().Result; QRResult = JsonConvert.DeserializeObject <QRResult>(jsonString); if (QRResult.bookingStatus == 0) { UserDialogs.Instance.HideLoading(); await DialogService.DisplayAlertAsync("", QRResult.message, "OK"); } else if (QRResult.bookingStatus == 2) { UserDialogs.Instance.HideLoading(); await DialogService.DisplayAlertAsync("", QRResult.message, "OK"); } else if (QRResult.bookingStatus == 1) { Settings.QrUserName = QRResult.QrUserName; NavigationService.GoBackAsync(); await NavigationService.NavigateAsync("ScannerSuccess"); //BusinessDetail = JsonConvert.DeserializeObject<BusinessDetail>(jsonString); UserDialogs.Instance.HideLoading(); } } else { UserDialogs.Instance.HideLoading(); //await NavigationService.NavigateAsync("ScannerFail"); var a = await DialogService.DisplayAlertAsync("", "error!, This Booking seems not belongs to your account", "OK", "Cancel"); CustomScanPage.zxing.IsAnalyzing = true; //await NavigationService.NavigateAsync(new Uri("http://www.testapp.com/Home", UriKind.Absolute)); //await NavigationService.NavigateAsync("CustomScanPage"); } } finally { client.Dispose(); } } catch (Exception e) { UserDialogs.Instance.HideLoading(); await DialogService.DisplayAlertAsync("", e.Message, "OK"); } }