错误:verifier._reset 不是函数。当尝试使用 firebase 使用手机登录时,请反应本机和 Expo

2024-02-04

我正在尝试在我的反应本机应用程序中实现电话登录,但出现以下错误:

verifier._reset is not a function. (In 'verifier._reset()', 'verifier._reset' is undefined)
at http://192.168.1.2:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&minify=false:126633:27 in <unknown>
at node_modules/tslib/tslib.js:60:8 in createExporter
at node_modules/tslib/tslib.js:18:0 in <global>
at http://192.168.1.2:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&minify=false:116838:35 in rejected

这就是我尝试实现签名的方式:


const SignUp = () => {
    const [phoneNumber, setPhoneNumber] = useState("")
    const recaptchaVerifier = React.useRef(null);
    const auth = getAuth(app)

    const sendCode = async () => {
        console.log(recaptchaVerifier.current)
        signInWithPhoneNumber(auth, phoneNumber, recaptchaVerifier.current!)
            .then(r => {
            console.log("Hej!")
        }).catch(err=>{
            console.log(err)
        })
    }

    return (
        <SafeAreaView
        style={tw.style('w-full')}>
            <FirebaseRecaptchaVerifierModal
                ref={recaptchaVerifier}
                firebaseConfig={app.options}
                attemptInvisibleVerification={true}
            />
            <TextInput
                style={tw.style('w-1/2', 'shadow', 'border', 'rounded', 'py-2', 'px-3', 'text-gray-700')}
                onChangeText={setPhoneNumber}
                keyboardType="phone-pad"
            />
           <Button title={"Send Code"} onPress={sendCode}/>
        </SafeAreaView>
    )

}

export default SignUp

我也尝试过这样实现:const phoneProvider = new PhoneAuthProvider(auth) const verificationId = await phoneProvider.verifyPhoneNumber(phoneNumber, recaptchaVerifier.current!)但我得到了相同的结果。

我没有想法,所以任何帮助将不胜感激。


更新到最新版本expo-firebase-recaptcha应该修复它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误:verifier._reset 不是函数。当尝试使用 firebase 使用手机登录时,请反应本机和 Expo 的相关文章

随机推荐