I’ve been trying to introduce a “Are you sure you want to exit” feature on a certain page in my app. However, I’ve been trying to use “platform.registerBackButtonAction” which doesn’t appear to fire at all when using the back button on the NavBar. Is there another way to handle this certain back button? Or will I have to get rid of it?
That does work fine for the hardware button. I’m concerned about the back button that appears on the navbar however. This isn’t fired when I press that
The back button event is triggered when the user presses the native platform’s back button, also referred to as the “hardware” back button. This event is only used within Cordova apps running on Android and Windows platforms. This event is not fired on iOS since iOS doesn’t come with a hardware back button in the same sense an Android or Windows device does.
Consider hiding the navbar back button if the platform is Android. You can do so by getting a reference to it in your pages with something like
@ViewChild(Navbar) navbar: Navbar;
And
if (this.platform.is('android')) {
this.navbar.hideBackButton = true;
}
Personally, since I switched over to Android I gave up using or expecting to use a navbar.backButton cold turkey. Hiding it might save you some unnecessary frustration.