Not able to disable back press in ionic

I am not able to disable the back press button.
I am using the the code" onHardwareBackButton(callback) ".
In callback function i am getting the alert successfully, but the back press will close the current page.
Please help me, how can i disable the default functionality of the back press.

I’m assuming you’re trying to disable the Android back button since you’re referencing a hardware back button. This is not an ionic topic, but at best a phonegap topic. Regardless, this should do it for you.

document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(e) {
  e.preventDefault();
}

Thanks for your help but the problem is still not solved.
On back press “onBackKeyDown(e)” is called but still it exits the app.

Try this code.
I use it on various apps, and works as intented.

	//=================================================
	if(!$rootScope.$viewHistory.backView){
		$scope.backButton = $ionicPlatform.registerBackButtonAction( function () {
			$ionicViewService.nextViewOptions({ disableBack: true });
			$state.go('home');
		}, 105 );
		$scope.$on('$destroy', $scope.backButton);
	}
})

If the app has a view back, it does the back page event, else (to prevent exiting the app), redirects to home (there yo ucan just do a return false.
The 105 stands for the priority of the events. There are various ionic events as close side menu, exit modal, etc. The 100 stands for back page or exit app.

still not working please reply