I need to use Phone authentication with firebase but every time I click on the button that sends the code to the user this error shows up, it's probably easy to solve but since my knowledge with firebase and react native is not very deep I can't find a solution.
Here is my code:
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>
)
}
}
I guess I need to insert this "firebase.initializeApp()" somewhere in my code. Please, how can I fix this issue?