Angular 财产';订阅';不存在于类型';承诺<;任何>';@ionic native/background地理位置插件出错

Angular 财产';订阅';不存在于类型';承诺<;任何>';@ionic native/background地理位置插件出错,angular,ionic4,Angular,Ionic4,我正在尝试为我的应用程序实现后台地理位置捕获,但我得到的错误是类型“Promise”上不存在属性“subscribe”。这是我的密码。 app.module.ts import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; providers: [ BackgroundGeolocation, ], liveLocation.service.ts import { Inj

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

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

 providers: [
    BackgroundGeolocation,
    ],
liveLocation.service.ts

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);


  });

  }
}
错误:

  ERROR in src/app/service/liveLocation/live-location.service.ts(25,4): error TS2339: Property 'subscribe' does not exist on type 'Promise<any>'.
src/app/service/liveLocation/live location.service.ts(25,4)中出现错误:错误TS2339:类型“Promise”上不存在属性“subscribe”。
有了承诺,它就是
。然后()

通过观察,你是正确的,它是代码>订阅()/<代码> < /p>替换<代码>订阅 > <代码> ,并在使用框架之前考虑了解RxJS和JS承诺。它没有给出任何选项,然后只能订阅可观察的。对于您需要的承诺。然后由操作员来解决。@nitish如果您没有
的intellisense For
,则表示您有错误的定义文件。但照上面所说的做就能解决问题。请检查这个插件@ionic native/background geolocation