Error in back

When i swipe back on a screen it still has a back view when it shouldn’t. It works when I use the goBack() function but when I swipe back on IOS it does not (meaning it has a back view). This occurs in the beforeEnter function. Has anyone faced this issue?

$scope.$on('$ionicView.beforeEnter', function() {
    alert($ionicHistory.backView()) 
})