I’ve implemented a condition that should exit the app when the back button is pressed on a certain page, but for other pages, it should navigate back as expected. Unfortunately, this behavior is not working correctly on all pages.
My code is given below:
document.addEventListener(‘backbutton’, function (router) {
var currentRoute = router.name;
if (currentRoute === ‘walk-through’) {
navigator.app.exit(); // Exit app if on walk-through page
}
else {
router.back();
}
});