0

i am new to ionic framework. Below code i have used in app.component.ts in constructor. My scenario is i have 3 screens A, B and C. A(HomeScreen) button click takes to B and B takes to C screen but when i press hardware back button it directly navigates to A screen. I am not getting how to bring back in sequence.

 if(this.platform.is("android")) {
       this.platform.backButton.subscribe(() => {
               if(this.router.url== '/tabs/home') {
                 navigator['app'].exitApp();
               }
             })
          }

Thanks in advance

santy
  • 19
  • 6
  • I think you should read this: https://stackoverflow.com/questions/55024239/my-hardware-back-button-action-is-not-working-in-ionic-4?rq=1 – Rahul Pamnani Mar 31 '20 at 18:13
  • Use backbutton.subscribewithpriority(99999... and continue – Mostafa Harb Mar 31 '20 at 18:19
  • @RahulPamnani from other pages it directly comes to home page where i want backward navigation in sequence – santy Apr 01 '20 at 06:28
  • @MostafaHarb i tried your solution, but its now working. From home pages i am able to exit the app but from other pages(for eample: if i am at 4th page then it should come back in sequence like 3...2...1, but it directly comes from 4th to 1st page) – santy Apr 01 '20 at 06:32

0 Answers0