In my application, I have this alert:
let confirm = this.alertCtrl.create({
title: 'Blabla',
message: 'blablabla',
buttons: [button1, button2, button3],
enableBackdropDismiss: false
});
confirm.present();
Also, when the application is resumed, the application should redirect to login page. No problem in making that work.
The problem comes, when I open the popup and resume the application. The application does redirect correctly, but the popup remains opened.
Is there a solution to programatically close all the popups opened? The resume function is called from app.component:
this.platform.resume.subscribe(() => {});
For this reason I cannot call confirm variable and close this popup.
Open the alerts from common page(provider) by calling presentAlert() method.
And in onresume subscription, call the dismissAlert() method to close all opened alerts.
You can subscribe to the same event from different places. So, you can call
this.platform.resume.subscribe(() => {});
from the component where yourconfirm
variable is accessible.I can't add a comment on Sabari's answer because my rep isn't high enough yet but I can confirm that his method works. I am currently implementing methods in my components to allow the app to go back in its steps when the user presses the device's Back button, but instances of AlertController, AlertSheetController and similar were problematic.
The only change that I made in comparison to his solution was to implement a boolean called logoutStarted that changed to true whenever AlertController presented an alert.
Doing this, I was able to shut down the alert from the method this.platform.registerBackButtonAction(() =>{}