Ionic 4: Display Alert Before App goes to background

Hi how to display an alert before an app moves to background?

Got it!!!
Inn app.component.ts file

public resumed:boolean = false;
  constructor(
    private platform: Platform,
  ) {    
    this.platform.resume.subscribe((res) => {
      if(this.resumed == false){
      
         alert("resumed");
          this.resumed = true;
        }
        
      }); 
      this.platform.pause.subscribe((paus) => {
      this.resumed = false;
      alert("pausing");
      });
  }

Im faced with same problem in my ionic 4 project.
But above code does not work for me.
I want to use this ability in my page.
can you guide me to do this?
Thank you