I haven't been able to get it to work for a few weeks now the Hardware Back Button. currently when we click back button the app is closed.
this.platform.backButton.subscribeWithPriority(-1, () => {
console.log("test")
});
CodePudding user response:
I found a solution :
import { App } from '@capacitor/app';
App.addListener('backButton', ({ canGoBack }) => {
console.log(canGoBack);
if(canGoBack){
window.history.back();
} else {
App.exitApp();
}
});
watch out, on android : registerPlugin(com.capacitorjs.plugins.app.AppPlugin.class);