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

时间:2020-11-01 10:51:55

标签: firebase authentication xamarin xamarin.forms cross-platform

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

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");
            }
        }

1 个答案:

答案 0 :(得分:0)

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

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");
        }
    }