ionic-native-transitions icon indicating copy to clipboard operation
ionic-native-transitions copied to clipboard

Add option to not register the hardware back button action

Open zemax2468 opened this issue 10 years ago • 5 comments

I want to be able to use my custom hardware back button action and not use the one defined in ionic-native-transition

zemax2468 avatar Jun 14 '16 09:06 zemax2468

I've tried the zemax modifications on the dist/ionic-native-transitions.js file without success with the hardware button action.

Device: Moto G 2013 OS: Android KitKat 4.4.4

thgfrzm avatar Jun 29 '16 13:06 thgfrzm

What is your issue @thgfrzm ? My change is only to remove the hardware back button action that is defined by the ionic-native-transition plugin because I already have a specific action registered in my app.

Be careful: ionic is also registering his own hardware back button action (so even if you put hasAlreadyRegisterBackButtonAction to true, the back button action will work)

zemax2468 avatar Jun 29 '16 14:06 zemax2468

Hi @zemax2468 ! Previously the use of ionic-native-transitions plugin, I've implemented a verification to show a popup "Want exit the application?" if the hardware back button pressed in some views. With the plugin, this action doesn't work. The hardware button always work like the back view. Then, I've tried your solution, but didn't work for me. :/

on the .run block:

$ionicPlatform.registerBackButtonAction(function(event){
  console.log("registerBackButtonAction found!"); 
 // never printed on console after use ionic-native-transitions
  if($state.$current.name === "login" || $state.$current.name === "home"){
    $ionicPopup.show({
      title: "Want close the app?",
      buttons: [
        {text: "Cancel", type: "button-stable button-clear"},
        {
           text: "Close",  type: "button-positive", 
           onTap: function(event) {ionic.platform.exitApp();}
        }
      ]
    });
  } else if($state.$current.name === "register"){
    $ionicHistory.clearCache();
    $ionicHistory.goBack(-1);
  } else if($state.$current.name === "detail"){
    $ionicHistory.goBack(-1);
  }
}, 100);

thgfrzm avatar Jun 29 '16 16:06 thgfrzm

Hi. It's weird because on my side, I have the same kind of code and everything is working fine with my update ! And if you add a breakpoint on the registerBackButtonAction in ionic-native-transition with hasAlreadyRegisterBackButtonAction = true, is it called or not ?

zemax2468 avatar Jul 06 '16 09:07 zemax2468

I have not tried yet

thgfrzm avatar Jul 19 '16 14:07 thgfrzm