How do I check if ionic popover is opened or closed

I want to know how to check whether ionic popover is closed or opened using if statements. My current code
doesn’t work. Below is my code:

 presentPopover(event: Event) {
    this.popover = this.popoverCtrl.create(PopoverPage);
    this.popover.present({ ev: event });

  }

if(this.popover)
{
//condition goes here
}
else
{
// condition goes here
}

Can you back up a bit and explain what you’re fundamentally trying to achieve? I think storing popovers (and alerts and loading indicators and so on) in object properties is a mistake, because it facilitates doing things with them that you don’t want to do (reusing them, double-dismissing them).

I want to close the opened popover when the back button is pressed. and if the popover is closed, I want to minimize the app then when back button is pressed

In that case, what I would do is to register a back button action that dismisses the popover at the time the popover is presented, and in the popover’s onDidDismiss() unregister that action. You can have multiple back button actions registered, and use the priority level to have the “kill popover” one take precedence over the “minimize app” one while the popover is open. Does that make sense?

I need help with the code to check whether the popover is opened or closed

You don’t need to check that. The popover knows. If its onDidDismiss() hasn’t been called yet, then it’s open, so unregister the back button action that closes the popover in said onDidDismiss().

Can u pls help me with some code because I am confused

can u pls help me with some code because I am confused now

Something like this (untested):

export class AppComponent {
  constructor(plat: Platform) {
    plat.ready().then(() => {
      plat.registerBackButtonAction(() => minimizeApp());
    });
  }
}

export class SomePage {
  constructor(private _plat: Platform, private _popovers: PopoverController) {}

  popPopover(): void {
    let popover = this._popovers.create();
    let doDismiss = () => popover.dismiss();
    let unregBackButton = this._plat.registerBackButtonAction(doDismiss, 5);
    popover.onDidDismiss(unregBackButton);
    popover.present();
  }
}

I want to close the popover with the back button when the popover is open.
on the other hand, when the popover is already closed, then on pressing the backbutton, the app shoud be minimized.
That is how the popover in whatsapp works. U can check it out

No sense this makes.

Sorry
I want to close the popover with the back button when the popover is open.
on the other hand, when the popover is already closed, then on pressing the backbutton, the app shoud be minimized.
That is how the popover in whatsapp works. U can check it out

Please explain how my code does not meet your needs, and stop telling me to install other apps. I have zero desire to do so.

your code can minimize the app when the pop up is closed. but I want the popover to be closed with the back button when the popover is opened . After closing the popover with the back button, when the back button is pressed again then it should minimize the app

What you describe is precisely how the code is supposed to function. Did you actually try it? What happened?

Thanks man…tried the code. It works perfectly