How to detect if the game is running on the background?

Hi, I want the game to log out when you enter suspended mode or when you enter to another app or program for a certain amount of time.
I don’t know how to do this and maybe Phaser has a function for this, or if I have to look somewhere else.

Hi,
I do it this way but i’m not sure if it’s a good practice to use this.game

this.game.events.on('blur', () =>
{
    // code here ...
});

this.game.events.on('focus', () =>
 {
     // code here ...
});

It worked! thank you!
Btw, for me it worked the same if I used “game” instead of “this.game”