Any workaround for Firebase Firestore persistence in Expo?
See original GitHub issueHi!!
I am facing a problem in expo and react native using Firesbase Firestore. I am trying to persist it but I get the error
Error enabling offline storage. Falling back to storage disabled: FirebaseError: [code=unimplemented]: This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.
Is there any way to persist it? Or not possible?
(async () => {
try {
// Try to enable the firebase auth persistence
await firebase.enableAuthPersistence(); <------------------ Works good!
} catch (err) {
console.log(err);
}
// Try to enable the firestore persistence
try {
await firebase.enableFirestorePersistence(); <------------- Not working
} catch (err) {
console.log(err);
}
})().then(() => {
// Listen the user's auth state
unsubscribe = firebase.auth.onAuthStateChanged((authUser) => {
Note: This code is implemented in a Splash Screen. I only show the login form after running it.
Also, here is the code for my firebase class (context provider)
export default class Firebase {
constructor() {
if (!firebase.apps.length) {
// Initialize App
firebase.initializeApp(Constants.manifest.web.config.firebase);
// Initialize firebase services
this.auth = firebase.auth();
this.db = firebase.firestore();
this.storage = firebase.storage();
this.functions = firebase.functions();
}
}
enableAuthPersistence = () =>
this.auth.setPersistence(firebase.auth.Auth.Persistence.LOCAL);
enableFirestorePersistence = () => this.db.enablePersistence();
...
}
Tested in Samsung galaxy s8+ and iPhone 11.
"react-native": "^0.63.3",
"expo": "39.0.0",
"firebase": "7.9.0",
"firebase-tools": "^8.4.3",
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
firebase firestore offline persistence FirebaseError
1 Answer 1 · Problem is that I already ejected expo but tried expo-firestore-offline-persistence anyways, it threw up the same error as above....
Read more >Access data offline | Firestore - Firebase
To enable persistence, call the enablePersistence method. Cloud Firestore's cache isn't automatically cleared between sessions. Consequently, if your web app ...
Read more >expo-firestore-offline-persistence - npm
Enable Firestore offline persistence in Expo/React Native apps without detaching from Expo.. Latest version: 0.1.0, last published: 2 years ...
Read more >Cloud Firestore - React Native Firebase
import firestore from '@react-native-firebase/firestore'; const usersCollection = firestore().collection('Users');. The collection method returns a ...
Read more >Firebase Alternatives – Top 10 Competitors - Back4App Blog
Firebase works with a closed-source NoSQL database for Firestore and the Real-Time database. It imposes users the restrictions of a NoSQL database, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was using Firebase/firestore and “expo-firestore-offline-persistence” to save and read saved objects. I upgraded to Expo SDK42 and now I have this exception. FirebaseError: You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.
I noticed that expo-firestore-offline-persistence is not maintained anymore. Is it possible to deal with that without going to native code?
Hi @VictorioMolina, it’s a “known issue” that the standard Firebase JS SDK isn’t fully working in a React Native or Expo environment. It needs more context that’s only possible through native code, that’s why we have multiple Expo Firebare packages to help in that. I would suggest taking a look at the “using firebase” docs and try using the
expo-firebase*
packages instead. If that doesn’t work for you, please let us know! You can create a new issue for the stuff you encounter.Hope this helps!