Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Enabling offline for firebase realtime database using Ionic app with capacitor

I am using ionic with firebase realtime database and capacitor 3. I intend to enable offline capabilities. I have built the app using ionic cap build and then opened in xcode. Then following url https://firebase.google.com/docs/database/ios/offline-capabilities I added the below code in AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        Database.database().isPersistenceEnabled = true

        return true
    }

Now to test i ran the app with wifi on and got the data from firebase db. after this i killed the app and turned off wifi. However, on launching the app it does not load the data.

Is there anything else i am missing here?

my key pod file has:

target 'App' do
  capacitor_pods
  # Add your Pods here
  pod 'FirebaseCore', '7.11.0' # Add this line
  pod 'Firebase/Database', '7.11.0' # Add this line
end

Below is my code that does not work and expected to:

getSeedConfig(){
  return new Promise((resolve, reject) =>{
        const doc = ref(this.db, 'config/seed');
        get(doc).then((snapshot) => {
          if (snapshot.exists()) {
            resolve(snapshot.val())
          } else {
            resolve(null)
          }
        }).catch((error) => {
          reject(error)
        });
  })
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When using a modern API in JavaScript there are not many cases where you need to return a custom promise anymore.

As far as I can tell this code that you now have:

getSeedConfig(){
  return new Promise((resolve, reject) =>{
        const doc = ref(this.db, 'config/seed');
        get(doc).then((snapshot) => {
          if (snapshot.exists()) {
            resolve(snapshot.val())
          } else {
            resolve(null)
          }
        }).catch((error) => {
          reject(error)
        });
  })
}

Can be shortened to:

getSeedConfig(){
  const doc = ref(this.db, 'config/seed');
  return get(doc).then((snapshot) => {
    return snapshot.val(); // 👈 returns null when the snapshot does not exist
  })
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda