简体   繁体   English

Xamarin Firebase 发送电子邮件验证

[英]Xamarin Firebase Sending Email Verification

good day how to send an email verification on Xamarin after you register an account I'm using this code but in sendEmailVerification it said FirebaseAuth does not define sendEmailVerification美好的一天如何在注册帐户后在 Xamarin 上发送电子邮件验证我正在使用此代码但在sendEmailVerification它说 FirebaseAuth 未定义sendEmailVerification

how can I fix this?我怎样才能解决这个问题?

private void LoginUser(string email, string password){

   if (input_password.Text == reinput_password.Text){

        auth.CreateUserWithEmailAndPassword(email, password)

          .AddOnCompleteListener(this, this);


        auth.sendEmailVerification(email)

           .AddOnCompleteListener(this, this);

    }

}

SendEmailVerification(Async) is a method on an FirebaseUser instance: SendEmailVerification(Async)FirebaseUser实例上的一个方法:

Example (using Xamarin async wrappers):示例(使用 Xamarin 异步包装器):

auth = FirebaseAuth.Instance;
using (var authResult = await auth.CreateUserWithEmailAndPasswordAsync("so@sushi.com", "stackoverflow"))
using (var user = authResult.User)
using (var actionCode = ActionCodeSettings.NewBuilder().SetAndroidPackageName(PackageName,true, "0").Build())
{
    await user.SendEmailVerificationAsync(actionCode);
}

my code works but there is something wrong IsEmailVerified always false我的代码有效但有问题 IsEmailVerified 总是错误

var authProvider = new FirebaseAuthProvider(new FirebaseConfig(webapi));

                        var auth = await authProvider.SignInWithEmailAndPasswordAsync(emailtxt.Text, passwordtxt.Text);
                        string gettoken = auth.FirebaseToken;
                        var content = await auth.GetFreshAuthAsync();
                        var serializedcontnet = JsonConvert.SerializeObject(content);
                        Preferences.Set("MyFirebaseRefreshToken", serializedcontnet);

                        if(content.User.IsEmailVerified == false)
                        {
                           var action = await App.Current.MainPage.DisplayAlert("Alert", "Your Email not activated,Do You want to Send Activation Code again?!", "Yes","No");

                            if(action)
                            {
                                await authProvider.SendEmailVerificationAsync(gettoken);
                            }

                        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM