Stop timer when use another app

i have a gamer with a timer, when i use another app the timer still working i want the timer stop when i am not in the game how i can achieve that
this is the code

    this.timer=this.paragraph.timer;
      this.counter$ = Observable.timer(0, this.tick)
    .take(this.timer)
    .map(() => --this.timer).finally(() =>{  this.endTimer();});

i also tried this code

  // this.counter$ = timer(0,this.tick).pipe(
    //   take(this.timer),
    //   map(() => --this.timer)
    // ).finally(() =>{  this.endTimer();});

Look into the pause and resume events.

I tried it and its works​:heart_eyes::heart_eyes:

Hey @rapropos you seem quite knowledgeable on here. Do you happen to know any alternative for these events when using Capacitor?

These events do not emit on Capacitor yet. I am struggling to find a work around for this.