有一段时间,我一直在尝试写一段代码,以便从Ionic中的应用程序构建中获得更长的时间。像大多数用户一样,我使用
https://ionicframework.com/docs/native/background-geolocation来编写代码。
这个插件不工作,我正在寻找不使用插件的最好的方法。
我已经完成了使用ionic 4原生文档中的代码,在2018年12月它起作用了。一段时间后,我今天打开了我的应用。应用程序崩溃了,我重写了代码。尝试了不同版本的插件,但都无济于事,它们不起作用。
setBackgroundTracking(){
this.backgroundGeolocation.configure(config)
.then(() => {
this.backgroundGeolocation.on('location').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 operations are 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
});
});
The above code is an exact copy paste from the documentation. and the code is buggy.
Property 'subscribe' does not exist on type 'Promise<any>'.ts(2339)
If you guys can fix the code or tell me another way to do it, please let me know. I have just been brainstorming would appreciate input/发布于 2019-05-24 14:04:12
您似乎无法从文档中复制/粘贴:
this.backgroundGeolocation.configure(config)
.then(() => {
this.backgroundGeolocation.on('location').subscribe((location: BackgroundGeolocationResponse) => {
console.log(location);https://stackoverflow.com/questions/56283552
复制相似问题