【发布时间】:2020-04-30 11:25:09
【问题描述】:
我需要使用带有 Firebase 的电话身份验证,但是每次我单击将代码发送给用户的按钮时都会显示此错误,这可能很容易解决,但由于我对 firebase 和 react native 的了解不是很深,我找不到解决办法。
这是我的代码:
export default class VerifyCell extends Component{
static navigationOptions = {header: null}
constructor(props){
super(props);
this.state = {
code: '',
};
}
render(){
const celular = this.props.navigation.getParam('celular');
return (
<ScrollView style={styles.container}>
<HeaderIcon type='MaterialCommunityIcons' name='message-processing'/>
<Text style={styles.titulo}>Phone Verification</Text>
<Text style={styles.dica}>Insert the code that has been sent to you below</Text>
<FormItem onChangeText={ (code) => this.setState({code}) } texto='Code'/>
<View style={{marginBottom: '40%'}}></View>
<GradientButton texto='Send code' onPress={async () => {
const confirmation = await auth().signInWithPhoneNumber('+55 19995661551');
}}/>
<View style={styles.formButton}>
<GradientButton texto='Next' onPress={async () => {
try {
await confirmation.confirm(this.state.code); // User entered code
// Successful login - onAuthStateChanged is triggered
} catch (e) {
console.error(e); // Invalid code
}
this.props.navigation.navigate('CadastraDados', {celular: celular} )
}}/>
</View>
</ScrollView>
)
}
}
我想我需要在我的代码中的某处插入这个“firebase.initializeApp()”。请问,我该如何解决这个问题?
【问题讨论】:
-
听起来您没有完全按照说明将 Firebase 添加到您的应用。
标签: firebase react-native firebase-authentication