【问题标题】:Xamarin Forms Cross Platform App Authentication with FirebaseXamarin 使用 Firebase 形成跨平台应用程序身份验证
【发布时间】:2021-02-14 06:06:33
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的分享,请采纳为答案。它将帮助其他有类似问题的人。
    猜你喜欢
    • 1970-01-01
    • 2020-10-31
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    相关资源
    最近更新 更多