I am creating a mobile application for Android and ios using react-native
this app shows customers’ product
and can create accounts using Facebook and Google, I use Firebase to create accounts and save data
when running the application in an Android emulator works with no error
but when running using the simulator for ios shows me this error:-
ERROR Invariant Violation:
new NativeEventEmitter()
requires a
non-null argument., js engine: hermes LOG Running “ShoofMangment”
with {“rootTag”:1,”initialProps”:{“concurrentRoot”:false}} ERROR
Invariant Violation: “ShoofMangment” has not been registered. This can
happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponent
wasn’t called., js engine: hermes info
Stopping server
I using to npx react-native start --reset-cache
and using to pod install
and I using this library in my project
"@firebase/app": "^0.10.15",
"@firebase/component": "^0.6.10",
"@firebase/logger": "^0.4.3",
"@firebase/util": "^1.10.1",
"@invertase/react-native-apple-authentication": "^2.4.0",
"@react-native-async-storage/async-storage": "^2.0.0",
"@react-native-community/cli": "^15.0.0",
"@react-native-community/datetimepicker": "^8.2.0",
"@react-native-firebase/app": "^20.5.0",
"@react-native-firebase/auth": "^20.5.0",
"@react-native-firebase/database": "^20.5.0",
"@react-native-firebase/firestore": "^20.5.0",
"@react-native-firebase/storage": "^20.5.0",
"@react-native-google-signin/google-signin": "latest",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"firebase": "9.6.1",
"i18next": "^23.15.1",
"react": "18.3.1",
"react-i18next": "^15.0.1",
"react-native": "^0.75.3",
"react-native-animatable": "^1.4.0",
"react-native-collapsible": "^1.6.2",
"react-native-elements": "^3.4.3",
"react-native-fbsdk-next": "^13.0.0",
"react-native-geolocation-service": "^5.3.1",
"react-native-gesture-handler": "^2.19.0",
"react-native-image-picker": "^7.1.2",
"react-native-linear-gradient": "^2.8.3",
"react-native-localize": "^3.2.1",
"react-native-maps": "^1.15.6",
"react-native-permissions": "^4.1.5",
"react-native-qrcode-scanner": "^1.5.5",
"react-native-safe-area-context": "^4.11.0",
"react-native-screens": "^3.34.0",
"react-native-share": "^11.0.4",
"react-native-swiper": "^1.6.0",
"react-native-vector-icons": "^10.2.0",
"react-native-video": "^6.6.4"
and this is my App.js file code
import React, {useEffect, useState} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import AppNavigator from './src/navigation/AppNavigator';
import './assets/i18n';
import {Settings} from 'react-native-fbsdk-next';
import auth from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {ActivityIndicator, View} from 'react-native';
import {BottomNavigationProvider} from './src/navigation/BottomNavigationContext'; //
استيراد المزود
export default function App() {
const [isLoading, setIsLoading] = useState(true);
const [initialRoute, setInitialRoute] = useState('LoginScreen'); // تحديد الشاشة
الافتراضية
useEffect(() => {
// تهيئة Facebook SDK
Settings.initializeSDK();
// التحقق من حالة تسجيل الدخول باستخدام AsyncStorage و Firebase Auth
const checkLoginStatus = async () => {
try {
const userInfo = await AsyncStorage.getItem('user');
console.log('userInfo data from AsyncStorage:', userInfo);
if (userInfo) {
console.log('Navigating to DashboardScreen');
// إذا كان userInfo موجودًا في AsyncStorage، توجيه المستخدم إلى Dashboard
setInitialRoute('DashboardScreen');
setIsLoading(false);
} else {
console.log('Firebase User Logged in:');
// استخدام Firebase Auth للتحقق من حالة المستخدم
auth().onAuthStateChanged(user => {
if (user) {
// المستخدم مسجل دخول
setInitialRoute('DashboardScreen');
} else {
console.log('No user logged in, navigating to SplashScreen');
// المستخدم غير مسجل دخول
setInitialRoute('SplashScreen');
}
setIsLoading(false);
});
}
} catch (error) {
console.error('Error checking login status:', error);
setIsLoading(false);
setInitialRoute('SplashScreen');
}
};
checkLoginStatus();
}, []);
if (isLoading) {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<ActivityIndicator size="large" color="#0000ff" />
</View>
);
}
return (
<BottomNavigationProvider>
{/* تغليف المزود هنا */}
<NavigationContainer>
<AppNavigator initialRoute={initialRoute} />
</NavigationContainer>
</BottomNavigationProvider>
);
}