Hi,
I have written a piece of code to override the hardware back button functionality.
This was working earlier in this project, also its still working in my other project.
Don’t know exactly what’s the issue.
$ionicPlatform.registerBackButtonAction(function (e) {
alert(‘triggered’);
if($state.is(‘app.home’)){
e.preventDefault();
}
else if($state.is(‘app.login’)){
$ionicPopup.confirm({
title:‘Exit’,
template:‘Are you sure you want to exit?’
})
.then(function(res){
if(res){
ionic.Platform.exitApp();
}
else{
//some code
}
})
}
else{
$ionicHistory.goBack();
}
}, 100);
The registerBackButtonAction() method is never triggered and the alert for triggered is not executed on click of hardware button.
Please help
Thanks