我正在我的应用程序中实施 Firebase 身份验证。我开始面临这个问题,因为 firebase 包从“@react-native-firebase/auth”:“^12.4.0”升级到“@react-native-firebase/auth”:“^12.8.0”。
我已经检查了与此问题相关的旧问题,但它们太旧了,答案无法解决问题。
奇怪的是我有时能登录有时不能登录。 Play商店版本根本无法运行。总是显示这个错误。
以下是我正在使用的库: "@react-native-firebase/app": "^12.8.0", "@react-native-firebase/auth": "^12.8.0", “@react-native-firebase/messaging”:“^12.8.0”,
Firebase 应用程序中添加了所有 3 个(调试、发布、谷歌)SHA256 密钥。现在陷入死循环。
async function signInWithPhoneNumber() {
console.log('Inside the Phone Number +91', registration_id);
try {
const confirmation = await auth().signInWithPhoneNumber(
'+91' + registration_id,
);
setConfirm(confirmation);
} catch (_error) {
console.log(_error);
}
}
async function confirmCode(code) {
try {
result = await confirm.confirm(code);
uid = result.user.uid;
console.log('result from confirmcode function:', uid);
} catch (_error) {
console.log('Invalid code.', _error);
}
}
提前致谢。
function onAuthStateChanged(user) {
if (user) {
// Some Android devices can automatically process the verification code (OTP) message, and the user would NOT need to enter the code.
// Actually, if he/she tries to enter it, he/she will get an error message because the code was already used in the background.
// In this function, make sure you hide the component(s) for entering the code and/or navigate away from this screen.
// It is also recommended to display a message to the user informing him/her that he/she has successfully logged in.
}
}
useEffect(() => {
const subscriber = auth().onAuthStateChanged(onAuthStateChanged);
return subscriber; // unsubscribe on unmount
}, []);