$ionicPlatform.registerBackButtonAction event is not working for me in my mobile App
Please suggest me
$ionicPlatform.registerBackButtonAction event is not working for me in my mobile App
Please suggest me
Can you give some more information? Where do you have the code at? What are you trying to do?
Here’s an example in the app.run:
app.run(function($ionicPlatform, $state) {
// Override the android back button
$ionicPlatform.registerBackButtonAction(function () {
if ($state.current.name == "home") {
// do something for this state
} else {
navigator.app.backHistory();
}
}, 100);
});
var appstarter = angular.module(‘starter’, [‘ionic’, ‘starter.controllers’])
appstarter.run(function ($ionicPlatform, $ionicHistory) {
$ionicPlatform.ready(function () {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
$ionicPlatform.registerBackButtonAction(function (event) {
alert(1);
event.preventDefault();
}, 100);
});
This is my code in app.js I want to restrict android back button but this event is not firing.
Hey, even i have the same problem… did you get it resolved???
Hi,
I am having the same problem. I want to clear history when I tap to a tab. So I want to use registerBackButtonAction to handle this. But I am not able to get registerBackButtonAction worked.
What am I doing wrong? Is there anyone solved this issue?
Thanks in advance.
Hi! I worked most of the solutions until I added the plugin InAppBrowser, now I stopped working. What could be the problem?
Hey, Anyone found solution for this? I am also facing the same issue.