The app closes unexpectedly in ionic. i'm using ionic v-5 and codova v-10. i was trying to close the modal when the android hardware back button is pressed, but the app closes completely unexpectedly instead. i tried with the surfing the ionic forums for cordova the solution there dint worked for me.
i tried this piece of code in both app component and the modal component
this.platform.backButton.subscribeWithPriority(10, () => {
console.log('angular Handler was called!');
this.modal.dismiss();
});
and
this.platform.backButton.subscribe(() => {
console.log("back button pressed")
if(this.modal.top())
{
this.modal.dismiss();
}
});
Even though trying these both code it didn't worked still the app was closed when the back button is pressed. I'm trying this from very long time but not able find the solution!