The App Life Cycle in Ionic 2&3 (Inactive & Active)

Thulani Mtetwa
1 min readNov 28, 2017

This post will take you through how to monitor if your application is in active(The app is running in the foreground) state and inactive(The app is in the background) state.

$ ionic start blank BackFore blank

Then go ahead and …

cd ./BackFore

Go ahead to the following link. This is just to give you an idea of what the platform api can offer you.

In your src/app/app.component.ts , look out for the following.(Side Note: If the following does not exist add it to your project. Also an an improved code snippet of this is on the a gist provided to us by the good Sam Gallagher on the comment section).

import { Platform } from 'ionic-angular';...constructor(public platform: Platform) {   platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.platform.resume.subscribe((result)=>{//Foreground

});
this.platform.pause.subscribe((result)=>{//Background

});
...
});
}

--

--

Thulani Mtetwa

I am an iOS App Developer. And worked on multiple apps in the finance and insurance industry.