meteoriron-router

How to delete Iron Router history


I am using Iron router for meteor and want to create android mobile apps. I create login page that look like WhatsApp application. After user successfully login, i want to make sure that when user click back button,user will never go back to that page. Home page after login is the last page user will view if he keep click back button. So if user click two times back button in the homepage, the application will close.

I hope anyone understand my problem.

My problem is, the first time after user register, the android functionality to kill application after two times back click will not occur.Or can i replicate the two times back button function so if i am in my homepage(after login), and i click button two times, the application will close?


Solution

  • Iron:router has the option {replaceState: true} that you can use.

    To accomplish this, all that you need to do is to change your Router.go('home') to Router.go('home', {}, {replaceState: true}) in your redirect hook after login.

    With this when your use presses the back button, home will have replaced your login route in the history, and the user will not go to the login page.