Detecting when the app has been minimized/restored in Ionic 2

Hello there :slight_smile:

I am trying to figure out how to detect when my app has been “minimized” (ie. no longer is active) and when it is restored. It’s important because I want to disconnect/reconnect SocketIO when the app is restored and kill it when it’s minimized.

I’ve found docs on Ionic 1 with the “pause” and “refresh” events, but I can’t find any examples on how to use this with Ionic 2.

Any advise would be very appreciated!

Thank you!

You mean when the app is paused and resumed :

document.addEventListener("pause", () => {

  console.log('paused');
}, false);

document.addEventListener("resume", () => {

  console.log('resume');
}, false);
2 Likes

Thank you :slight_smile:
Very helpful!

1 Like

Put the topic as resolved via the icon image please.
You’ll find it at the bottom of each replies. Choose your best reply :wink:

Thanks in advance.

1 Like

Hi, It Didn’t work in Devapp. Is there any other way?