gpt4 book ai didi

firebase - 如何使用 sendEmailVerification() 方法

转载 作者:IT王子 更新时间:2023-10-29 07:12:10 24 4
gpt4 key购买 nike

尝试为 Firebase 设置 firebase_auth 包Flutter 中的电子邮件/密码身份验证方法,但需要电子邮件验证方面的帮助。

我遇到了 firebase_auth 包提供的 sendEmailVerification(); 方法,但需要一些关于设置它的建议。请问有人有可以遵循的工作代码示例吗?

// From firebase_auth package docs > https://pub.dartlang.org/documentation/firebase_auth/latest/firebase_auth/FirebaseUser/sendEmailVerification.html

Future<void> sendEmailVerification() async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await FirebaseAuth.channel.invokeMethod(
'sendEmailVerification', <String, String>{'app': _app.name});
}

如果可能的话,我们将不胜感激任何有关正确设置它的帮助、建议和指导以及要遵循的工作示例代码。

最佳答案

如果您创建一个 FirebaseUser,此方法将起作用。可以这样使用:

await _auth.createUserWithEmailAndPassword (
email: //wherever you set their email,
password: //wherever you set their password,
).then((FirebaseUser user) {
//If a user is successfully created with an appropriate email
if (user != null){
user.sendEmailVerification();
}
})
.catchError();

关于firebase - 如何使用 sendEmailVerification() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55371405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com