[英]Firebase email verification WITHOUT creating an account in React Native
我對 Firebase 中的電子郵件驗證有疑問。 我在這里找到的問題的解決方案。 但是當我將代碼轉換為原生反應時。 它沒有按預期工作。
我的功能
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 應向提供的電子郵件用戶發送確認代碼。
您應該閱讀文檔https://rnfirebase.io/reference/auth/user#updateEmail ,下面的代碼應該可以工作。 如果不打印你得到了什么錯誤。
登錄屏幕
const onSignIn = () => {
auth()
.signInAnonymously()
.then(() => {
console.log('User signed in anonymously');
.catch((error) => {
if (error.code === 'auth/operation-not-allowed') {
console.log('Enable anonymous in your firebase console.');
}
console.error(error);
});
navigation.push('SignUpConfirm');
};
注冊確認畫面
useEffect(() => {
auth().onAuthStateChanged((userIs) =>
userIs
.updateEmail('jasurkurbanov96@gmail.com')
.then(() =>
userIs
.sendEmailVerification()
.then(() => console.log('email verificiation sent')),
)
.catch((err) => console.log('This is', err)),
);
}, []);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.