Platform.pause / platform.resume not working?


I’m using the typical way to detect app pause / resume in a Cordova app. But this does not work with capacitor:

initializeApp() {
    this.platform.ready().then(() => {
      console.log('App is ready');

      this.platform.pause.subscribe(test => {
        console.log('App paused.');
      this.platform.resume.subscribe(test => {
        console.log('App resumed.');

the console.logs are never printed…


Good catch, doesn’t look like we’re emitting the pause and resume events in Capacitor. Making a note of that.

In the meantime you can use the App API to listen for app state changes (pause/resume):

import { Plugins, AppState } from '@capacitor/core';

const { App } = Plugins;
App.addListener('appStateChange', (state: AppState) => {
  // state.isActive contains the active state
  console.log('App state changed. Is active?', state.isActive);


Thanks @max,

The App API works, I had actually found out by reading the documentation :wink: