离子原生诊断 - 如何知道用户何时回到应用程序

问题描述 投票:0回答:1

在我的Ionic应用程序中,我要求用户通过以下代码启用位置:

let alert = this.alertCtrl.create({
  title: 'Posizione',
  message: 'Abilita il GPS per localizzare la tua posizione.',
  buttons: [
    {
      text: 'No',
      role: 'cancel',
      handler: () => {
      }
    },
    {
      text: 'Sì',
      handler: () => {
        this.diagnostic.switchToLocationSettings();

        }
    }
  ]
});
alert.present();

我正在寻找一种方法来了解用户何时退出位置设置并返回到应用程序,以便我可以调用geolocate方法,否则只有在用户打开页面时才会调用。因此,此刻他将不得不转到另一个页面然后回到地理定位的页面来定位自己。我不知道,是否存在一种回调?或者是否有另一种方法在关闭设置后立即调用geolocate?

ionic-framework location ionic3 diagnostics
1个回答
1
投票

您可以使用离子2的Platform.resume,如here所述。

当本机平台从后台拉出应用程序时,将发出resume事件。当Cordova应用程序从后台发出时,此事件将会发出,但是,它不会在标准Web浏览器上触发。

© www.soinside.com 2019 - 2024. All rights reserved.