Override App API hardware back button

#1

I want to remove the code line that exists the app when the hardware back button is pressed in the code source of App API

#2

this code that handles hardware back button in app.js

 App.prototype.goBack = function() {
        if (this._menuCtrl && this._menuCtrl.isOpen()) {
            return this._menuCtrl.close();
        }
        var navPromise = this.navPop();
        if (navPromise === null) {
            // no views to go back to
            // let's exit the app
            if (this._config.getBoolean('navExitApp', true)) {
                (void 0) /* console.debug */ ;
                 this._plt.exitApp();
            }
        }
        return navPromise;
    };

I want to delete the line this._plt.exitApp(); .
How to override this function in the cleanest way possible?
Or am I obliged to change the code source ?

#3
platform.registerBackButtonAction(() => {
    // Do stuff here
})

Tried that?

#4

Yea I tried that. When I press hardware back button it takes time to go back (650ms) on a samsung a3 2014 probably because this method is a promise. But I changed the code source it works just fine and it’s fast.