Where/how do you listen to appStateChange?


I’m trying to catch an event when the app moves back to the foreground. I have the following in the AppComponent from the ionic v4 sidemenu template. But it never seems to catch the event. suggestions?

  selector: 'app-root',
  templateUrl: 'app.component.html'
export class AppComponent {
  public appPages = [
      title: 'List',
      url: '/list',
      icon: 'list'

    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
  ) {

  initializeApp() {
    this.platform.ready().then(() => {

  async listenAppState(){
    const device = await Device.getInfo();
    switch (device.platform){
      case 'ios':
      case 'android':
        App.addListener('appStateChange', (state: AppState) => {
          // state.isActive contains the active state
          console.log('"&&& App state changed. Is active?', state.isActive);


Nevermind. it works as written. There was an exception in console statement I was using JSON.stringify(item).

But I would like suggestions on how to catch these events in the Safari Debugger.