Xamarin使用Firebase进行跨平台应用程序身份验证

问题描述

我想接收用户电子邮件并向他们发送重置密码请求。 我没有解决方案的运气。

private async void Forgetpassword_Clicked(object sende,EventArgs e)
        {

            var authReset = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));
            try
            {
                var email = UserLoginEmail.Text;

                var auth = await authReset.SendPasswordResetEmailAsync(UserLoginEmail.Text);
                var content = await auth.GetFreshAuthAsync();
                var serializedcontent = JsonConvert.SerializeObject(content);
                Preferences.Set("MyFirebaseRefreshToken",serializedcontent);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await App.Current.MainPage.displayAlert("Alert","Invalid email or password","OK");
            }
        }

解决方法

我知道了。但是,如果有更好的方法,请告诉我

private async void ForgetPassword_Clicked(object sende,EventArgs e)
    {

        var authReset = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));
        try
        {
            var email = UserLoginEmail.Text;

            var auth = authReset.SendPasswordResetEmailAsync(UserLoginEmail.Text);
            await App.Current.MainPage.DisplayAlert("Alert","Email Sent","OK");

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            await App.Current.MainPage.DisplayAlert("Alert","Invalid email or password","OK");
        }
    }