iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

Is it possible to check if we can go back in history or not? #1300

Open alphanso opened 9 years ago

alphanso commented 9 years ago

I am creating an android app using meteor + cordova, When user clicks back button on landing page it goes back to same page again which feels buggy. Is there any way to detect if we can't go back in history and ask user to exit the app.

johnantoni commented 9 years ago

this would be great, rather than relying on window.location and hacking it.

mahenn commented 8 years ago

just add below lines. It will work.

if(Meteor.isCordova) { Meteor.startup(function() { /back button does not exit app.. below function check and exit if back from home page / document.addEventListener("backbutton", function(e) { e.preventDefault();
if (document.location.pathname =="/") { navigator.app.exitApp(); } else { history.go(-1); } }); }); }