We have a Prism MAUI app that is deployed to Android and iOS. In some of the ViewModels I would like to be able to catch back navigation using the Prism interface IConfirmNavigationAsync
.
This works perfectly in Android but in iOS it never gets called.
When the Back button is pressed in iOS I see this message in the debug output
NavigationPage has encountered an unhandled GoBack. Be sure to inherit from PrismNavigationPage.
That is thrown by the NavigationPageSystemGoBackBehavior when the PageNavigationService.NavigationSource == Device. This makes me think that I should be handling that Back button myself or offering up a Prism one but I don't know how to do that.
FWIW the following fire just fine
- OnNavigatedFrom
- IDestructible.Destroy
- OnDisappearing
We initialise Prism like this:
static void BuildPrism(PrismAppBuilder prism)
{
Type viewModelToShow = null;
viewModelToShow = typeof(HomeViewModel);
prism.CreateWindow(
string.Format("NavigationPage/{0}", viewModelToShow.Name),
HandleNavigationError);
}