$ionicPlatform.registerBackButtonAction priority 102 (or higher) works but 101 or 100 does not


#1

Strangely enough, when trying to catch the use of the back button on view changes, using $ionicPlatform.registerBackButtonAction with a priority of 100 or 101, did not work and did not trigger the back button code, but setting it to 102 (or anything above that) made it work. How is that? The code is very basic:

Within the angular .run() function:

$ionicPlatform.registerBackButtonAction(function() {
  log.info('Device Back button pressed');
  if (true) { // your check here
    $ionicPopup.confirm({
      title: 'System warning',
      template: 'are you sure you want to exit?'
    }).then(function(res) {
      if (res) {
        ionic.Platform.exitApp();
      }
    });
  }
}, 102);

#2

In addition to this, using 102 means for some reason that hitting back when side menu is open no longer closes the menu, when it used to do that just fine.

I have not posted the app code, cos I would not know where to start in terms of what to include. Let me know if there is anything specific I need to post, but technically any custom code cant make priorities cant go wrong like this surely…?

Any help appreciated :stuck_out_tongue:


#3

Below is the result of debugging the hardwareBackButtonClick in ionic, and seeing what actions are registered currently. (Note, the variable ‘c’ is due to the uglification).
So I can see that there are actions for 100, 101, 102. The 102 one is my function, but how do I debug the others, how can I find out what they are?
Does anyone from ionic know how to dissect the stored functions on those priorities?

Im trying to give lots of detail here so hopefully, ‘someone’, ‘anyone’, will be able to help out?