Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

347
Visualizações
firebase firestore offline persistence FirebaseError

I searched for several hours to implement firestore offline persistence because its crucial for my app to work. I handle multiple chats inside my app and its a fatal error to download data every time again.

This is my code sample, its the root App.js file which is the first one beeing called:

....
//imports related to firebase
import * as firebase from "firebase";
import ApiKeys from "./constants/ApiKeys";


export default function App() {
  //firebase project initialisation
  if (!firebase.apps.length) {
    firebase.initializeApp(ApiKeys);
    var db = firebase.firestore();
    db.settings({ experimentalForceLongPolling: true });
    console.log("DB INITIALISED");
    db.enablePersistence() //HERE IS THE PROBLEM
        .catch((err) => {
            if (err.code == 'failed-precondition') {
                // Multiple tabs open, persistence can only be enabled
                // in one tab at a a time.
                // ...
            } else if (err.code == 'unimplemented') {
                // The current browser does not support all of the
                // features required to enable persistence
                // ...
            }
      })
  };.....

The API Keys look like this:

const firebaseConfig = {
    apiKey: "***",
    authDomain: "***",
    databaseURL: "https://***",
    projectId: "***",
    storageBucket: "***",
    messagingSenderId: "***",
    appId: "***",
    measurementId: "***"
  };

  export default firebaseConfig;

I receive the following error which I can not work around:

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 have installed the complete "firebase" bundle and also access to @firebase/firestore, I checked this already, and I implemented it same as in the official docs. Everything works but when I want to enable the persistence... It crashes with the error mentioned above.

What can I do now? Do I miss another package, have I done something wrong?

As a sidenote, authentification persistence works perfectly inside my app, just the firestore persistence is failing.

Currently using firebase SDK 8.2.3

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have developed my app with Expo and was pointed to expo-firestore-offline-persistence. I notice on their page they talk about react-native-firebase for enabling persistence on RN - though that seems to require ejecting from Expo.

It seems this is an issue with polyfill on the RN platform. In other words, the Javascript that Firestore requires doesn't have everything necessary on the React Native platform - something that common browsers will have. So the "fix" is to leverage a component like react-native-firebase or expo-firestore-offline-persistence that give you that extra capability on native.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda