代码之家  ›  专栏  ›  技术社区  ›  AbhiRam

定位精度插件当我调用函数时什么也不会发生

  •  1
  • AbhiRam  · 技术社区  · 6 年前

    我在手机中构建了以下代码,没有任何错误,但是当我单击按钮时,我需要检查设备位置启用与否,但是使用以下代码时,什么都没有发生。我使用的是Android 7.0版本,有人能帮我吗?我只需按照此链接了解如何编程启用和在爱奥尼亚框架或科尔多瓦中禁用GPS

    start(){
        this.locationAccuracy.canRequest().then((canRequest: boolean) => {
          if(canRequest) {
            this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(() => {
                console.log('Request successful.')
              },
              error => {
                console.log('Error requesting location permissions', error)
              }
            );
          }
        });
      }
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   AbhiRam    6 年前

    下面的代码解决了我的问题

    this.platform.ready().then((readySource) => {
    
          this.diagnostic.isLocationEnabled().then(
            (isAvailable) => {
              console.log('Is available? ' + isAvailable);
              alert('Is available? ' + isAvailable);
            }).catch((e) => {
              console.log(e);
              alert(JSON.stringify(e));
            });
    
        });