I want that if a user is logged in he can't go to the login and OTP page by hardware back button.
.controller('viewoemCtrl', function($rootScope,$scope,$http,$ionicPopup,$state,$ionicHistory,$ionicLoading,productService,$ionicPlatform) {
$scope.user = {}; //declares the object user
$ionicPlatform.onHardwareBackButton(function () {
if (true) { // your check here
$ionicPopup.confirm({
title: 'Exit from App!',
template: 'are you sure you want to exit?'
}).then(function (res) {
if (res) {
navigator.app.exitApp();
}
})
}
})
})