Platform Events for "pause" and "resume" Not Emitting?


#1

We are attempting to use the pause and resume events emitted by Platform in Ionic 2.

We are not seeing these events emitted.

Here is the code we are using, any feedback would be appreciated.

platform.ready().then(() => {
    StatusBar.overlaysWebView(false);
    StatusBar.backgroundColorByHexString("#622B7D");
    document.addEventListener("pause", function() {
        // not firing
        console.log("paused")
    }, false);
    document.addEventListener("resume", function() {
        // not firing
        console.log("resumed")
    }, false);
});

#2

Hi, the following code worked for me.

constructor( private platform: Platform ) {
    platform.ready().then(() => {    
        this.platform.pause.subscribe(() => {
            console.log('[INFO] App paused');
        });

        this.platform.resume.subscribe(() => {
            console.log('[INFO] App resumed');
        });
    });

Hope it helps.


#3

The above code did not work for me.


#4

could you provice ionic info?


#5

Sorry, I was trying it in PWA, as per the following issue it won’t work on web.