【发布时间】:2019-01-31 01:12:40
【问题描述】:
我需要在我的应用中实现后台地理位置。我访问了这个ionic documentation,代码如下:
this.backgroundGeolocation.configure(config)
.subscribe((location: BackgroundGeolocationResponse) => {
console.log(location);
// IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
// and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
// IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
this.backgroundGeolocation.finish(); // FOR IOS ONLY
});
当我在我的应用程序中使用此代码时,我的 ts-lint 指责 configure(config) 方法是 Promise<any> 而不是 Observable,所以,我不能使用 subscribe。我将subscribe 切换为then。但是当我运行时,会在下面显示此错误:
ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
at BackgroundGeolocation.configure (vendor.js:82333)
// error below ommited
有人可以帮助我吗?
【问题讨论】:
标签: cordova ionic-framework geolocation ionic3