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


#1

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!


#2

You mean when the app is paused and resumed :

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

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

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

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

#3

Thank you :slight_smile:
Very helpful!


#4

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

Thanks in advance.