Firebase : Error (auth/network-request-failed) with Expo and react native

I tried to build an app with Expo and react native but I faced (auth/network-request-failed) issues, the google service is active on the device (simulator for Android and real iPhone for IOS) and I’m connected to my Google account.

I also tried to prevent the page from reloading and use other wifi or network but nothing changed. After some research, all I see is I’m not the only one to face this error I haven’t found any valuable answer to fix this problem. so if someone can help me I would appreciate it. Thanks for helping.

Here is my code:

firebase.js:

import { getApp, getApps, initializeApp } from 'firebase/app';
import { initializeAuth, getReactNativePersistence, getAuth } from 'firebase/auth';
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
import AsyncStorage from '@react-native-async-storage/async-storage';

let firebaseApp;

export const getFirebaseApp = () => {
// copy from the firebase config
if (!firebaseApp) {
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: ""
};

    firebaseApp = getApps().length === 0 ? initializeApp(firebaseConfig) : getApp();
    initializeAuth(app, {
       persistence: getReactNativePersistence(ReactNativeAsyncStorage)
    })

}
return firebaseApp;
};

SignUp.js:

import { SafeAreaView, StyleSheet, Text, View,StatusBar as RNStatusBar,Platform, TouchableOpacityComponent, Button, Pressable, Alert } from 'react-native';
import { TextInput } from 'react-native-gesture-handler';
import { TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { useState } from 'react';
import Checkbox from 'expo-checkbox';
import { getFirebaseApp } from '../firebase';
import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth';
import { getFirestore, collection, doc, setDoc } from 'firebase/firestore';


export default Signup = function({navigation} ) {
  const [isPasswordShown, setIsPasswordShown] = useState(false);
  const [isChecked, setIsChecked] = useState(false);
  const navLogin = () => navigation.navigate('Login');
  const firebaseApp = getFirebaseApp();
  const db = getFirestore(firebaseApp);
  const col = collection(db, 'users')
  const [fullName, setFullName] = useState('');
  const [phone, setPhone] = useState('');
  const [userType, setUserType] = useState('Gym');
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const registerUser = async (email, password, fullName, phone, userType) => {

    try {
      const userCredential = await createUserWithEmailAndPassword(getAuth(firebaseApp), email, password);
      const user = userCredential.user;
  
      await setDoc(doc(col, user.uid),{
        fullName,
        phone,
        userType
      });
  
      console.log('account created successfully');
      Alert.alert('Success', 'Account created successfully');
      navigation.navigate('Home')
    } catch (error) {
      console.error('account create failed', error.message);
      Alert.alert('Error', 'Account create failed: '+ error.message);
    }
  };
  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.signing}>
        {/* Title form */}
        <View style={{marginVertical:22}}>
          <Text style={styles.title}>SignUp</Text>
        </View>

        {/* SignUp form */}
        <View style={styles.filed}>

        {/* Fullname form */}
        <Text style={styles.text}>
            Full Name
          </Text>

          <View style={styles.form}>
            <TextInput 
              placeholder='Enter your Name'
              placeholderTextColor={'black'}
              style={{
                width: '100%'
              }}
              value = {fullName}
              onChangeText={text => setFullName(text)}
              >
            </TextInput>
          </View>


          {/* Email address form */}
          <Text style={styles.text}>
            Email address
          </Text>

          <View style={styles.form}>
            <TextInput 
              placeholder='Enter your Email address'
              placeholderTextColor={'black'}
              keyboardType='email-address'
              style={{
                width: '100%'
              }}
              value={email}
              onChangeText={text => setEmail(text)}>
            </TextInput>
          </View>

          {/* password form */}
          <Text style={styles.text}>
            Password
          </Text>

          <View style={styles.form}>
            <TextInput 
              placeholder='Enter your Password'
              placeholderTextColor={'black'}
              secureTextEntry={isPasswordShown}
              style={{
                width: '100%'
              }}
              value={password}
              onChangeText={text => setPassword(text)}>
            </TextInput>
            <TouchableOpacity
              onPress={() => setIsPasswordShown(!isPasswordShown)}
              style={{
                position: 'absolute',
                right:12
              }}>
                {
                  isPasswordShown == true ? (
                    <Ionicons name='eye-off' size={24} color={'black'}/>
                  ) : (
                    <Ionicons name='eye' size={24} color={'black'}/>
                  )
                }
              </TouchableOpacity>
          </View>


          {/* Phone number form */}
          <Text style={styles.text}>
              Phone number
          </Text>

          <View style={styles.form}>
            <TextInput 
              placeholder='+61'
              keyboardType='numeric'
              placeholderTextColor={'black'}
              style={{
                width: '100%'
              }}
              value={phone}
              onChangeText={text => setPhone(text)}>
            </TextInput>
          </View>

          {/* UserType */}
          <Text style={styles.text}>
              User Type : {userType}
          </Text>
        </View>

        {/* agree form */}
        <View style={{ flexDirection: 'row', marginVertical:6}}>
          <Checkbox 
          style={{marginRight: 8}}
          value={isChecked}
          onValueChange={setIsChecked}
          color={isChecked ? 'blue' : undefined}/>
          <Text> I aggree to the terms and conditions</Text>
        </View>
        <Button 
          title='Sign Up'
          filled
          style={{
            marginTop: 18,
            marginBottom: 4
          }}
          onPress={registerUser}
        />

New contributor

Fox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật