rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

Firebase.initializeApp does not work in callback #196

Closed daichi000 closed 3 years ago

daichi000 commented 3 years ago

Hi, I tried this code, but the App crashes

Future<void> callback(LocationDto locationDto) async {
  await Firebase.initializeApp();
  Firestore.instance.collection("test").document().setData({
     "test": "data",
  });
  final SendPort send = IsolateNameServer.lookupPortByName(isolateName);
  send?.send(locationDto);
}

If except for await Firebase.initializeApp();, App doesn’t crash, but firestore doesn't work. Can you please let me know the possible reason?

irwing844 commented 3 years ago

You must register the plugin. https://github.com/rekab-app/background_locator/wiki/Use-other-plugins-in-callback

joandervieira commented 3 years ago

I have the same problem. What is the name package of the firebase ? FLTFirebaseCorePlugin.register(with: registrar(forPlugin: "io.flutter.plugins.firebase.core")!) Is it ?