Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

await not working correctly

$
0
0

Hi,

I am making an app using Xamarin Forms (PCL) and I am having trouble with an await call that seemingly exits prematurely.
What I have is button on a login page when the button is pressed it makes an await call to login... and when its done it should push the appropriate modal.
This functionality works on my Android device as well as the iOS simulator simulating a iPhone 5S on 9.1.

But it does not work on an actual iPhone 5S that is on 9.1.
By not working I mean that the variable go seems to be set to false every time. I put breakpoints on the return statements in the login function of the LoginViewModel() but they don't even get hit.

Again, the login works fine in the iOS simulator as well as on my Android device... so I'm guessing it must have something to do with the iOS device... looking for any tips or solutions.

Wondering if anyone had any suggestions or have run into the same issue. Here is some code:

this.ButtonLogin.Clicked += async(sender, eventArgs) =>
            {
                this.AILogin.IsVisible = true;
                var vm = this.BindingContext as LoginViewModel;
                var go = await vm.Login(this.Username.Text, this.Password.Text);
                if(go)
                {
                    this.AILogin.IsVisible = false;
                    RegisterDevice();
                    //await this.Navigation.PushModalAsync(((MasterDetailPage)new RootPage()), false);
                    var hasPasswordBeenReset = Convert.ToBoolean(App.Current.Properties["BtmPasswordResetFlag"]);
                    if (hasPasswordBeenReset)
                    {
                        await this.Navigation.PushModalAsync(new NavigationPage(new ChangePasswordView()), false);
                    }
                    else
                    {
                        RegisterDevice();
                        await this.Navigation.PushModalAsync(new NavigationPage(new MessageListView()), false);
                    }
                    //RegisterDevice();
                    //await this.Navigation.PushModalAsync(((MasterDetailPage)new RootPage()), false);
                }
                else
                {
                    this.AILogin.IsVisible = false;
                    await DisplayAlert("Authentication Failed", "Try Again", "Try Again");
                }
            };

Thank you for reading.


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>