【问题标题】:Ionic background geolocation issue not working in background mode离子背景地理定位问题在后台模式下不起作用
【发布时间】:2021-10-11 08:30:52
【问题描述】:

我正在开发一个 IONIC 应用程序,该应用程序在谷歌地图上显示服务提供商的活动位置,目的地为用户 (lat,lon),来源为服务提供商的活动位置 (lat,lon)。

一旦服务提供商按下按钮,我们将使用“ionic cordova plugin add @mauron85/cordova-plugin-background-geolocation”插件获取他的位置,以在 30 秒后获取服务提供商的位置。

应用在前台时有效,但在应用处于非活动状态或后序时失败。

如果需要,我还使用“ionic cordova plugin add cordova-plugin-background-mode”来启用后台进程。但问题仍然存在。

如果APP在后台,我无法获取服务提供商的位置。

我在构造函数中的代码如下:

this.backgroundGeolocation.configure(this.config).then(() => 
    {
      this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => 
      {
          this.latitude = String(location.latitude);
          this.longitude = String(location.longitude);
          this.saveCordinates();
      });
    });

每 30 秒后我使用 this.backgroundGeolocation.start();

初始化填充 this.latitude, this.longitude 然后我用 this.saveCordinates();功能

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    我也尝试使用该插件但失败了。经过几个小时的调试,我放弃了,改用另一个插件。

    如果您使用电容器,我建议使用this one。它可以在 Android 和 iOS 上完美运行。对于 Cordova,我听说 this one 很好,但我没有使用它,所以我不确定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 2018-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多