Добрый день! Подскажите пожалуйста как исправить эту ошибку
Error sending code: [Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()]
login.js
import React, {useState} from 'react';
import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native';
import auth from '@react-native-firebase/auth';
import firestore from '@react-native-firebase/firestore';
import { useNavigation } from '@react-navigation/native';
export default function Login() {
const [phoneNumber, setPhoneNumber] = useState('');
const [code, setCode] = useState('');
const [confirm, setConfirm] = useState(null);
const navigation = useNavigation();
const signInWithPhoneNumber = async()=>{
try{
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
setConfirm(confirmation);
}catch(error){
console.log('Error sending code:', error);
}
};
const confirmCode = async()=>{
try{
const userCredential = await confirm.confirm(code);
const user = userCredential.user;
const userDocument = await firestore()
.collection('users')
.doc(user.uid)
.get();
if(userDocument.exists){
navigation.navigate('Dashboard');
}else{
navigation.navigate('Detail', {uid: user.uid});
}
}catch(error){
console.log('Invalid code.', error);
}
};
return (
Phone Number Authentication Using Firebase
{!confirm ?(
<>
Enter your phone number
placeholder='+7 (000) 000 00 00'
value={phoneNumber}
onChangeText={setPhoneNumber}
keyboardType='phone-pad'
/>
Send Code
>
):(
<>
Enter the code sent to your phone:
placeholder='Enter code'
value={code}
onChangeText={setCode}
keyboardType='number-pad'
/>
confirm Code
>
)}
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
app.json
"expo": {
"plugins": ["@react-native-firebase/app", "@react-native-firebase/auth"],
}
"android": {
"googleServicesFile": "./google-services.json",
}