- SDK Version: 48
- Platforms: Android/iOS
@react-native-firebase/app
: v18.4.0react-native
: v0.71.8
Description:
I’m encountering an issue with my Expo mobile app where I’m unable to fetch data from Firebase Realtime Database. Before migrating to Expo SDK 48, I had been using the Firebase JavaScript SDK. During the migration, I decided to switch to @react-native-firebase
. I’ve successfully configured Firebase in my app without any problems. However, when it comes to accessing the Realtime Database, I’m facing difficulties.
Symptoms:
- I have set up Firebase Realtime Database correctly, including the database URL in my Firebase configuration.
- There are no error messages or exceptions thrown in the console, and the app appears to be running without any issues.
- I have verified that my app has a stable internet connection because Firebase authentication and Firestore are working as expected.
- My Firebase security rules allow read access to the data I’m trying to retrieve.
Code Snippet:
javascriptCopy code
import { database } from '@react-native-firebase/database';
database()
.ref('/users/')
.on(
'value',
(snapshot) => {
console.log('User exists: ', snapshot.exists());
console.log('User data: ', snapshot.val());
},
(err) => {
console.error('---- pushToken errrr = ', err);
},
);
Current Status:
When I run the above code to fetch data from the Realtime Database, none of the consoles is displayed. However, there are no errors or warnings in the console. To investigate further, I checked the connection using the reference to the special “.info/connected” path, and it always returns false
.
I’ve attempted various troubleshooting steps, including checking Firebase rules, verifying the database path, ensuring correct Firebase configuration, and downgrading firebase to old versions. Unfortunately, the problem persists.
Additional Note:
It’s worth noting that the app works fine on the first install, but after closing it and reopening it later, the problem shows up.
I would greatly appreciate any insights, suggestions, or guidance from the community to help me resolve this issue.