var viewMain = app.views.create(’.view-main’, {
stackPages: true,
pushState: true,
pushStateSeparator: ‘#’
});
@autocar you should need to try this Function.
open your cordova-app.js and find this function name handleAndroidBackButton and replace. hope working for you
handleAndroidBackButton: function () {
var f7 = cordovaApp.f7;
const $ = f7.$;
if (f7.device.electron) return;
cordovaApp.backButtonTimestamp = new Date().getTime();
document.addEventListener('backbutton', function (e) {
if ($('.actions-modal.modal-in').length) {
f7.actions.close('.actions-modal.modal-in');
e.preventDefault();
return false;
}
if ($('.dialog.modal-in').length) {
f7.dialog.close('.dialog.modal-in');
e.preventDefault();
return false;
}
if ($('.sheet-modal.modal-in').length) {
f7.sheet.close('.sheet-modal.modal-in');
e.preventDefault();
return false;
}
if ($('.popover.modal-in').length) {
f7.popover.close('.popover.modal-in');
e.preventDefault();
return false;
}
if ($('.popup.modal-in').length) {
f7.popup.close('.popup.modal-in');
e.preventDefault();
return false;
}
const currentView = f7.views.current;
if (currentView && currentView.router && currentView.router.history.length > 1) {
currentView.router.back();
e.preventDefault();
return false;
}
if ($('.panel.panel-in').length) {
f7.panel.close('.panel.panel-in');
e.preventDefault();
return false;
}
if (new Date().getTime() - cordovaApp.backButtonTimestamp < 250) {
cordovaApp.backButtonTimestamp = new Date().getTime();
if (window.navigator.app && window.navigator.app.exitApp) {
f7.dialog.confirm('Are you sure you want to close this activity?', function () {
setTimeout(() => {
window.navigator.app.exitApp();
}, 1000);
});
}
return true;
}
cordovaApp.backButtonTimestamp = new Date().getTime();
e.preventDefault();
return false;
}, false);
},
Thanks for reply hadley
I have not installed cordova in my app is there any other way to handle this or i need to install cordova