Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
21,105
The error is pretty straight forward and if you take a look at the documentation, you can see that you need to have a firebaseConfig object,
var firebaseConfig = {
apiKey: "api-key",
authDomain: "project-id.firebaseapp.com",
databaseURL: "https://project-id.firebaseio.com",
projectId: "project-id",
storageBucket: "project-id.appspot.com",
messagingSenderId: "sender-id",
appId: "app-id",
measurementId: "G-measurement-id",
};
with all the relevant data for your application and then you need to use the command:
firebase.initializeApp(firebaseConfig);
This is usually inserted inside your App.js
file
Author by
Mateus99
Updated on January 14, 2020Comments
-
Mateus99 over 4 years
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?
-
Nithyanandan Sathiyanathan almost 4 yearsfor ios what could be the problem
-
tomerpacific almost 4 years@NithyanandanSathiyanathan - please post another question with code and more explanation.
-
Pratap Sharma over 3 yearsreact-native does not support firebase javascript-SDK
-
haleonj almost 3 yearsAs @PratapSharma suggests, there is a difference between the React Native Firebase project and Google's own Firebase project, despite both having a JavaScript interface. This bug concerns React Native and iOS.