首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ionic 4-背景地理位置问题

ionic 4-背景地理位置问题
EN

Stack Overflow用户
提问于 2019-05-24 06:11:54
回答 1查看 207关注 0票数 1

有一段时间,我一直在尝试写一段代码,以便从Ionic中的应用程序构建中获得更长的时间。像大多数用户一样,我使用

https://ionicframework.com/docs/native/background-geolocation来编写代码。

这个插件不工作,我正在寻找不使用插件的最好的方法。

我已经完成了使用ionic 4原生文档中的代码,在2018年12月它起作用了。一段时间后,我今天打开了我的应用。应用程序崩溃了,我重写了代码。尝试了不同版本的插件,但都无济于事,它们不起作用。

代码语言:javascript
复制
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/
EN

Stack Overflow用户

发布于 2019-05-24 14:04:12

您似乎无法从文档中复制/粘贴:

代码语言:javascript
复制
this.backgroundGeolocation.configure(config)
  .then(() => {

    this.backgroundGeolocation.on('location').subscribe((location: BackgroundGeolocationResponse) => {
      console.log(location);
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56283552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档