Unregister back button action


On my app, I have:
this.platform.registerBackButtonAction(this.backButtonAction.bind(this), 500);
Which does

private backButtonAction() {

        if (this.nav.canGoBack())

But this code does not dismiss modals, so I added in my modal:
this.platform.registerBackButtonAction(this.dismiss.bind(this), 600);

Which does indeed dismiss the modal on back button, but makes the other listener not to work (fair, lower priority).

Is there a way to unregister this action (when leaving the modal)?
I have another case where in the same page, you have a 3 steps progress, and when you are on step 2, I wan’t back button to go back to step 1. Without unregistering the listener I kind of can’t.



This might be of use :slight_smile: Specifically the overlay bits, you can stick to only registering one back button action.


Thanks! Very helpful indeed.


@AmitMY according to the docs:

The call to registerBackButtonAction returns a function that deregisters the custom function you just registered. E.g.:

    deregisterFunction = this.platform.registerBackButtonAction(()=>{

a little late to the party, but I hope it helps anyone else that comes looking for an answer on this topic…


thanks for this answer