【问题标题】:send latest location to the Firestore even when the app is terminated using carp_background_location即使使用 carp_background_location 终止应用程序,也将最新位置发送到 Firestore
【发布时间】:2022-01-19 01:27:06
【问题描述】:

我正在尝试将从 carp_background_location 收到的最新位置更新发送到 Firestore。当应用程序在 Android 上终止时,回调不会被执行。我还没有尝试过它是否可以在 iOS 上运行。

我正在关注包提供的这个示例: example

我想要的是使用此回调将位置发送到 Firestore:

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

  }

这在前台或后台都可以正常工作,但在应用程序终止时就不行了。

非常感谢问题的解决方案或有关如何使其发挥作用的指导。

【问题讨论】:

    标签: android ios firebase flutter google-cloud-firestore


    【解决方案1】:

    https://pub.dev/packages/background_fetch看看这个,应该可以解决你的问题

    【讨论】:

    • 我应该开始在后台收听流还是使用这个插件定期获取位置?我还没有理解这种方法..请澄清
    • 我个人更喜欢定期获取位置。
    猜你喜欢
    • 1970-01-01
    • 2015-05-01
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 2016-04-07
    • 2021-09-25
    • 2016-08-19
    相关资源
    最近更新 更多