示例#1
0
        private async AsyncTask DoLogin()
        {
            try
            {
                // :code-block-start:login-async
                // :state-start: final
                var user = await App.RealmApp.LogInAsync(Credentials.EmailPassword(email, password));

                // :state-end: :state-uncomment-start: start
                //// TODO: pass the email and password properties to LogInAsync
                //// var user = await ...
                // :state-uncomment-end:
                // :code-block-end:
                if (user != null)
                {
                    var projectPage = new ProjectPage();
                    await Navigation.PushAsync(projectPage);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Login Failed", ex.Message, "OK");
            }
        }
        private async AsyncTask DoLogin()
        {
            try
            {
                var user = await App.RealmApp.LogInAsync(Credentials.EmailPassword(email, password));

                if (user != null)
                {
                    var projectPage = new ProjectPage();
                    await Navigation.PushAsync(projectPage);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Login Failed", ex.Message, "OK");
            }
        }