0
votes

As my Ionic4 application starts, it comes to login page and once user enter credentials and log in. It will redirect to tabbed interface ion-tabs.

For login, I have localhost:8100/#/login.

For Request, I have localhost:8100/#/tabs/requests

For Inbox, I have localhost:8100/#/tabs/inbox

For Outbox, I have localhost:8100/#/tabs/outbox

Request, Inbox and Outbox page comes in Tabbed Interface. Whereas Login page is separate and it's an entry point of application.

I want to register hardware back button in such a way that if it's in login page and hardware back button is pressed then it should close the application but if application is in tabbed interface ( routes from /tabs/... ) and hardware back button is pressed then it should raise an alert box that "Are you sure want to go back" or something.

I have tried this example but it didn't work for me.

https://medium.com/@reviloera.../ionic-framewok-4-hardware-back-button-9b45df233414

1
Link is broken. - SGalea
I've updated the question - Yash Jain

1 Answers

0
votes

use

  this.subscription = this.platform.backButton.subscribe(()=>{ 
      // Check with Router what you want to do here
      navigator['app'].exitApp(); 
  });