How to remove all pop-ups on the platform?

In my application, I have this warning:

let confirm = this.alertCtrl.create({ title: 'Blabla', message: 'blablabla', buttons: [button1, button2, button3], enableBackdropDismiss: false }); confirm.present(); 

Also, when the application resumes, the application should redirect to the login page. No problem doing this job.

The problem occurs when I open a popup and resume the application. The application redirects correctly, but the popup remains open.

Is there a solution for programmatically closing all pop-ups? The resume function is called from app.component:

 this.platform.resume.subscribe(() => {}); 

For this reason, I cannot call the confirming variable and close this popup.

0
source share
3 answers

You can subscribe to the same event from different places. So you can call this.platform.resume.subscribe(() => {}); from the component where your confirm variable is available.

+1
source

Open alerts from the shared page (provider) by calling the presentAlert () method.

And in the onresume subscription, call the rejectAlert () method to close all open warnings.

 alerts: Alert[] = []; presentAlert() { let confirm = this.alertCtrl.create({ title: 'Blabla', message: 'blablabla', buttons: [button1, button2, button3], enableBackdropDismiss: false }); this.alerts.push(confirm); confirm.present(); } dismissAlert() { console.log('Dismissed alert'); if (this.alerts.length) { this.alerts.forEach(e => { e.dismiss(); }); } this.alerts = []; } 
0
source

I cannot add a comment to Sabari's answer because my representative is still not tall enough, but I can confirm that his method works. I am currently implementing methods in my components so that the application can return to its steps when the user clicks the back button on the device, but instances of AlertController, AlertSheetController and the like were problematic.

The only change I made compared to his solution was to implement a boolean logoutStarted value that changed to true when the AlertController presented a warning.

 if (this.alerts.length > 0 || this.logoutStarted) { this.alerts.forEach(i => { i.dismiss(); this.alerts = []; this.logoutStarted = false; }); } 

By doing this, I was able to disconnect the warning from the this.platform.registerBackButtonAction (() => {} method

0
source

All Articles