I’ve searched around a great deal to no avail on this topic. I must be using the wrong terminology. I’m not referring to the back button within the app.
My goal is to integrate the ionic app with the conventional web browser back button history. Ideally, I’d like to prevent the user from backing out of the site completely until prompted, and to add pages to the regular browser history so that if the user presses the button he/she will be taken back to the previous app ‘page’, rather than the last URL in the location bar.
Any suggestions on where to look or sample code would be very welcome.
Thanks in advance.
Hi @davidquinnjacobs - I’m trying to do the same thing, ultimately have the back button be reasonable in an Ionic app when running in the browser. Did you reach any conclusions on this?
No, it is still a big issue for us. I’ve put it on the back burner for now, hoping it will be resolved. I would think it would be a big issue for anyone using the code for progressive web apps.
Thanks for the info. I completely agree - seems like a big issue for any PWA.
Based on the recent commits it looks like the Ionic team is working on this lazy-loading and navigation/routing story. Hopefully something stable will be ready soon.
Agreed, this is a huge issue. It makes Ionic virtually unusable for me. Sadly, it seems like I’ve been saying that about various Ionic issues for the past two years of my life. I keep crossing my fingers that the next release will finally bring stability and usability, but I’m losing patience and losing faith. It seems like I spend more time updating to the latest Ionic versions than actually working on my own app. But recent commits are promising:
As it stands now, the only approach I can see is adding a popstate listener in the app constructor, but that fires after Ionic nav has already done its thing (and onbeforeunload never fires), so may be too late. I’m not really clear how far I’ll be able to get with reconstructing discarded nav stacks, etc. with this approach. It would be very hacky if it worked at all, probably better to just wait for next release. My issues may relate to nested navigation since I’m pushing / popping a nav history within a single tab. Might work better outside of tabs.