Browser vs. app navigation

Looking for some help to understand how to reconcile browser navigation and mobile app navigation. The Ionic docs indicate that navigation is primarily stack based, which appears to be hierarchical, using whatever nav topology a particular app requires. But in a desktop browser context, the browser has it’s own stack which is historical, not structural. So in practice, it seems to make more sense on the desktop to simply use NavigationController.setRoot() instead of push(). But somewhere in the collaboration between the browser and the nav controller, things get jacked up. Specifically, I periodically get three issues: 1) After navigating around in my app and clicking the browser Back button, the app’s own nav bar Back button appears as if it’s trying to pop from it’s stack instead of setRoot. 2) The views that it loads when clicking that button are not correct represent a correct history. 3) When clicking the browser’s back button, I get an “Invalid views to insert” exception, which is apparently due to a bug described at https://github.com/ionic-team/ionic/issues/11374.

Besides the bug fix, I’d love to get some kind of explanation of how to handle the browser history correctly. My current implementation basically uses a custom nav controller that uses push/pop on mobile, when appropriate, and setRoot exclusively on desktop.

1 Like