shprink / ionic-native-transitions

[Maintenance only] Native transitions (iOS & Android) for Ionic Framework
https://www.npmjs.com/package/ionic-native-transitions
MIT License
572 stars 112 forks source link

Add option to not register the hardware back button action #109

Closed zemax2468 closed 4 months ago

zemax2468 commented 8 years ago

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

thgfrzm commented 8 years ago

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

zemax2468 commented 8 years ago

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)

thgfrzm commented 8 years ago

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);
zemax2468 commented 8 years ago

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 ?

thgfrzm commented 8 years ago

I have not tried yet