离子本机诊断 - 如何知道用户何时返回应用程序
ionic native diagnostic - how to know when the user has come back to the app
在我的 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?
您可以使用离子 2 的 Platform.resume,如 here 所述。
The resume event emits when the native platform pulls the application
out from the background. This event would emit when a Cordova app
comes out from the background, however, it would not fire on a
standard web browser.
在我的 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?
您可以使用离子 2 的 Platform.resume,如 here 所述。
The resume event emits when the native platform pulls the application out from the background. This event would emit when a Cordova app comes out from the background, however, it would not fire on a standard web browser.