@ ionic-native / background-geolocation插件中的类型'Promise <any>'不存在属性'subscribe'

时间:2019-03-12 12:42:36

标签: angular ionic4

我正在尝试为我的应用程序实现后台地理位置捕获,但是遇到错误“ Promise”类型不存在属性“ subscribe”。这是我的代码。 app.module.ts

model = joblib.load("your_saved.model")
model.get_booster().feature_names = ["your", "feature", "name", "list"]
xgboost.plot_importance(model.get_booster())

liveLocation.service.ts

import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';

 providers: [
    BackgroundGeolocation,
    ],

错误:

import { Injectable } from '@angular/core';
import { BackgroundGeolocation, BackgroundGeolocationConfig, BackgroundGeolocationResponse }
 from '@ionic-native/background-geolocation/ngx';

const config: BackgroundGeolocationConfig = {
  desiredAccuracy: 10,
  stationaryRadius: 20,
  distanceFilter: 30,
  debug: true, //  enable this hear sounds for background-geolocation life-cycle.
  stopOnTerminate: false, // enable this to clear background location settings when the app terminates
};

@Injectable({
  providedIn: 'root'
})


export class LiveLocationService {

  constructor(private backgroundGeolocation: BackgroundGeolocation) { }

  LiveLocationCapturing(){

    this.backgroundGeolocation.configure(config)
  .subscribe((location: BackgroundGeolocationResponse) => {

    console.log(location);


  });

  }
}

0 个答案:

没有答案