Issue
I am using Ionic
Framework with React
. I want to run a code when platform.pause as mentioned in ionic-react-platform.
But the codes in react documents are unbelievably for angular instead of react!
I want exactly code below, but for react not for angular. Can any one help me with it please?
import { Platform } from '@ionic/angular';
@Component({...})
export class MyPage {
constructor(public platform: Platform) {
}
init(){
this.platform.pause.subscribe(async () => {
alert('Pause event detected');
});
}
}
Solution
You can try by setting a listener inside your App component (or wherever you need it)
import { App } from '@capacitor/app';
App.addListener('appStateChange', ({ isActive }) => {
// state.isActive contains the active state
console.log('App state changed. Is App in foreground?', isActive);
});
Answered By - nomadev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.