【发布时间】:2020-12-26 22:49:27
【问题描述】:
我对 Firebase 中的电子邮件验证有疑问。我找到了here的问题的解决方案。但是当我将代码转换为原生反应时。它没有按预期工作。
我的功能
const onSignIn = () => {
auth()
.signInAnonymously()
.then(() => {
console.log('User signed in anonymously');
auth()
.onAuthStateChanged((user) => {
user.updateEmail('jasurkurbanov96@gmail.com');
user.sendEmailVerification();
})
.catch(function (error) {
console.log('error', error);
});
})
.catch((error) => {
if (error.code === 'auth/operation-not-allowed') {
console.log('Enable anonymous in your firebase console.');
}
console.error(error);
});
navigation.push('SignUpConfirm');
};
基本上我想要实现的是。当用户进入应用程序时,我只需要显示电子邮件输入。一旦用户 输入电子邮件地址,Firebase 应向提供的电子邮件用户发送确认码。
【问题讨论】:
-
错误是什么?这两个调用都是异步的,所以如果你不等待 updateEmail 完成,sendEmailVerification 会抛出一个错误。
-
1) 你怎么知道它是异步的? 2) 我的电子邮件正在更新,但 sendEmailVerification 不起作用。 3)我会看到错误日志而不是
标签: javascript reactjs firebase react-native firebase-authentication