-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description
When adding the IConfirmNavigation or IConfirmNavigationAsync to a ViewModel and implementing the CanNavigate / CanNavigateAsync method, the method is not called on iOS when using the NavBar back button. The method is called on Windows and Android when using NavBar back buttons or hardware back button.
Interestingly enough the CanNavigate method is called when explicitly calling navigationService.GoBackAsync() on iOS, it is just the navbar back button on iOS that doesn't call the method.
I have created a sample app that demonstrates the issue, which can be found here
I checked to make sure this isn't a duplicate bug, the only mention I could find is in the discussions here and here
Environment:
I've reproduced the issue on the provided sample app on a physical iPhone 14 running iOS 18.1.1 and a simulated iPhone 14 running iOS 17.0
Please see the gifs below demonstrating the issue:
Windows:

Please let me know if you require any additional information
Steps to Reproduce
-
Clone the repository
-
Run the app on an iPhone or iPhone simulator
-
Tap on the "Go to child page" button
-
Tap on the navbar back button
Result: You'll be navigated back immediately -
Run the app on Android or Windows device
-
Tap on the go to child page button
-
Tap on the navbar back button
Result: You'll be shown an alert stating that you first need to check the checkbox before you'll be able to navigate back
Platform with bug
.NET MAUI
Affected platforms
iOS
Did you find any workaround?
You can create your own custom titleview with a custom back button that fires a command in the ViewModel, which calls navigationService.GoBackAsync() which will cause the CanNavigate method to be called on iOS as well.
Relevant log output

