I have a PWA application that is a SPA with internal navigation – there is a page stack and upon pressing the “back” button, the topmost page is removed to reveal the previous one.
It works perfectly using the in-app back button, but I cannot for the life of me get the Android hardware back button to work.
All the materials on here and elsewhere point to the solution of using history.pushState and then listening for the popstate event.
I have tried all the different possible solutions, but to no avail. The first back button press works as expected, but two presses in a row (regardless of time inbetween them, so not a “double-click”) always quit the app regardless of what I pushState into the history. If I interact with app in any other way (even as just randomly tapping on an empty area), then one back press works again.
Any ideas anyone?