private async Task TestLogin() { OTPView view = new OTPView(); view.Initialize(new Dictionary <string, string>() { { "phoneNumber", "7635850811" } }); await Task.Delay(100); await Navigation.PushAsync(new BottomNavigationPage()); await Task.Delay(10); }
/// <summary> /// Invoked when the Log In button is clicked. /// </summary> /// <param name="obj">The Object</param> private async void LoginClicked(object obj) { IsBusy = true; if (string.IsNullOrEmpty(PhoneNumber)) { await page.DisplayAlert("Incorrect Number", "Please enter your phone number first", "OK"); IsBusy = false; return; } if (PhoneNumber.Length != 10) { await page.DisplayAlert("Incorrect Number", "Please enter a 10 digit Phone Number", "OK"); IsBusy = false; return; } if (CrossConnectivity.Current.IsConnected) { try { var app = Application.Current as App; ShowHideBusyIndicator(true); Debug.WriteLine(@"Invoking the rest generate otp APi "); //Calling FireBaseToken Function string NotificationToken = await RetrieveToken(); Debug.WriteLine(@"Registration Token " + NotificationToken); //hardcodeMerchantID OtpResponse generateotp_response = await OTPDataService.Instance.GenerateOtp(PhoneNumber, NotificationToken); if (generateotp_response.Status.ToLower() == "success") { app.Merchantid = generateotp_response.Data.MerchantBranchId; DependencyService.Get <IHashService>().StartSMSRetriverReceiver(); app.SecurityAccessKey = generateotp_response.AccessKey; OTPView view = new OTPView(); view.Initialize(new Dictionary <string, string>() { { "phoneNumber", PhoneNumber } }); await Navigation.PushAsync(view); //AnalyticsFunction Analytics.TrackEvent("LoginClicked", new Dictionary <string, string> { { "UserPhoneNumber", PhoneNumber }, { "APP", "Py DigiCat" }, //hardcodeMerchantID { "MerchantBranchId", app.Merchantid } }); await Task.Delay(10); ShowHideBusyIndicator(false); } else { await page.DisplayAlert("INFO", "Unable to generate OTP. Please try again.", "Ok"); } } catch (Exception e) { Debug.WriteLine(@"Error in login " + e.Message); await page.DisplayAlert("Error", "Error in login ", "Ok"); } IsBusy = false; } else { try { DependencyService.Get <IToastMessage>().ShortTime("No Internet Connection"); } catch { } IsBusy = false; } }
/// <summary> /// Invoked when the Log In button is clicked. /// </summary> /// <param name="obj">The Object</param> private async void LoginClicked(object obj) { IsBusy = true; if (string.IsNullOrEmpty(PhoneNumber)) { await page.DisplayAlert("Incorrect Number", "Please enter your phone number.", "OK"); IsBusy = false; return; } if (PhoneNumber.Length != 10) { await page.DisplayAlert("Incorrect Number", "Please enter a 10 digit Phone Number", "OK"); IsBusy = false; return; } if (CrossConnectivity.Current.IsConnected) { try { var app = Application.Current as App; //AnalyticsFunction Analytics.TrackEvent("LoginClicked", new Dictionary <string, string> { { "UserPhoneNumber", PhoneNumber }, { "MerchantBranchId", app.ParentMerchantid } }); // Firebase token generation CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) => { System.Diagnostics.Debug.WriteLine($"NEW TOKEN : {p.Token}"); }; string token = CrossFirebasePushNotification.Current.Token; CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { System.Diagnostics.Debug.WriteLine("Received"); }; //Calling FireBaseToken Function Debug.WriteLine(@"Registration Token " + token); //hardcodeMerchantID Dictionary <string, string> generateotp_response = await OTPDataService.Instance.GenerateOtp(app.ParentMerchantid, PhoneNumber, token); if (generateotp_response["status"].ToLower() == "success") { DependencyService.Get <IHashService>().StartSMSRetriverReceiver(); app.SecurityAccessKey = generateotp_response["accessKey"]; OTPView view = new OTPView(); view.Initialize(new Dictionary <string, string>() { { "phoneNumber", PhoneNumber }, { "token", token } }); await Navigation.PushAsync(view); await Task.Delay(10); } else { await page.DisplayAlert("INFO", "Unable to generate OTP. Please try again.", "Ok"); } } catch (Exception e) { Debug.WriteLine(@"Error in login " + e.Message); await page.DisplayAlert("Error", "Error in login ", "Ok"); } IsBusy = false; } else { try { DependencyService.Get <IToastMessage>().ShortTime("No Internet Connection"); } catch { } IsBusy = false; } }
/// <summary> /// Invoked when the Log In button is clicked. /// </summary> /// <param name="obj">The Object</param> private async void LoginClicked(object obj) { IsBusy = true; try { var app = Application.Current as App; //var app = App.Current as App; ShowHideBusyIndicator(true); Debug.WriteLine(@"Invoking the rest generate otp APi "); //if (otp != null) if (string.IsNullOrEmpty(PhoneNumber)) { await page.DisplayAlert("Incorrect Number", "Please enter your phone number first", "OK"); IsBusy = false; return; } if (PhoneNumber.Length != 10) { await page.DisplayAlert("Incorrect Number", "Please enter a 10 digit Phone Number", "OK"); IsBusy = false; return; } Analytics.TrackEvent("LoginClicked", new Dictionary <string, string> { { "UserPhoneNumber", PhoneNumber }, //hardcodeMerchantID { "MerchantBranchId", "1" } }); Debug.WriteLine(@"Invoking the rest generate otp APi "); string NotificationToken = app.FireBaseToken; Debug.WriteLine(@"Registration Token " + NotificationToken); //hardcodeMerchantID Dictionary <string, string> generateotp_response = await OTPDataService.Instance.GenerateOtp("1", PhoneNumber, NotificationToken); Debug.WriteLine(@"Response received " + generateotp_response); if (generateotp_response["status"].ToLower() == "success") { app.SecurityAccessKey = generateotp_response["accessKey"]; OTPView view = new OTPView(); view.Initialize(new Dictionary <string, string>() { { "phoneNumber", PhoneNumber } }); await Navigation.PushAsync(view); await Task.Delay(10); ShowHideBusyIndicator(false); } else { await page.DisplayAlert("INFO", "Unable to generate OTP. Please try again.", "Ok"); } } catch (Exception e) { Debug.WriteLine(@"Error in login " + e.Message); await page.DisplayAlert("Error", "Error in login ", "Ok"); } IsBusy = false; }