1

I'm having a background process to track user location and update to the database. For firebase to be used in the background process after the app is closed (through the callback functions in package background_locator), I have to call

    DartPluginRegistrant.ensureInitialized();
    
    Firebase.initializeApp().then((_) {
        print("done initialize app in background");
    });

However, if this Firebase.initializeApp() is called after the Firebase.initializeApp() in the main thread, it will reset all listeners to the Firebase db that the main thread already established.

My question is, how can we correctly initialize the app in the background process without interfering the main process? And why does background process & main process share the same Firebase instances, but when I close the main process, the Firebase instances become uninitialized?

  • Were you able to make any progress on this issue? Having the same problem over here, waiting on a solution: https://stackoverflow.com/questions/75769480/performing-firebasefirestore-queries-from-multiple-isolates – Geralt von Riva Mar 21 '23 at 09:03

0 Answers0