I want to use the device back button event in ionic4 to do something but it not work.
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
this.backButtonEvent()
}
backButtonEvent() {
this.platform.backButton.subscribeWithPriority(2, () => {
console.log("clicked to the back button")
});
}
}
You can catch hardware back button event like this
this.sub = this.platform.backButton.subscribeWithPriority(9999, () => {
// Do your stuff here
});