[INVALID] Active view is a page or a modal?

Is there any way to guess if the current active view is a page or a modal?

In my app I register a custom hardware back action and I would be happy I don’t have to unregister/register it x time. Like guessing if I should perform a navController.pop or a viewController.dismiss …

According documentation, modal are pushed in the root nav so I was expecting to be able to guess if the modal is active by checking the navcontroller…but nope doesn’t work. Asking the navcontroller for the last view even when the modal is active still give back the last page…do I miss something?

I ended up writing a custom hardware back in each modals where it was needed … the above solution isn’t valid therefore I delete it