0

I'm trying to send the latest location update received from carp_background_location to Firestore. The callback doesn't get excuted when the app is terminated on Android. I haven't tried if it works on iOS yet.

I'm following this example provided by the package: example

What I want is to use this callback to send location to Firestore:

void onData(LocationDto dto) {
    // print(dtoToString(dto));
    print(dto);
    setState(() {
      lastLocation = dto;
      lastTimeLocation = DateTime.now();
    });
    pushDtoToFirebase()

  }

this works fine in the foreground or the background but not when the app is terminated.

I'd really appreciate a solution to the problem or guidance on how to make it work.

1 Answer 1

0

https://pub.dev/packages/background_fetch take a look at this, this should solve your issue

2
  • Should I start listening to the stream in the background or do periodic fetches of location using this plugin? I haven’t understood the approach yet.. please clarify Dec 15, 2021 at 23:19
  • i personally prefer periodic fetching of location. Dec 17, 2021 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.