I have a Cordova app that has a conditional statement when the Android back button is pressed. If we are on the root page I want it to do navigator.app.backHistory(), and when it's not on the root page I want it to run my own custom code. I've done it like so:
function onDeviceReady() {
document.addEventListener("backbutton", function(e) {
if(screenList.length <= 0) {
alert("fired");
navigator.app.backHistory();
} else {
//My custom code
}
}
}
My custom code runs as it should, and the alert fires when it should too, but navigator.app.backHistory() does nothing. Did this change recently? I'm using Cordova version 7.0.1