-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Android hardware back button stops working after redirecting navigation #18306
Comments
Hi, wondering if any thoughts on this one yet, I have yet to find a way around it. |
In my case, it only works when the app open first time. After navigating to next component, it can back to the previous page but not exit app. |
@huahuichin - did you subscribe to the
In my case all this works until I use the |
Hi, just wondering of anyone had a change to look at this? I can still find no other way of doing what I need to do. Cheers! |
Hi! Same issue for me, the subscription to hardware back button isn't working. I also tried to use But this code does't work either |
Same here in Ionic 4, the event never gets fired when I press the android back button, I have tried all the above methods. Also tried it with a fresh Ionic 4 project without success. |
Getting the same problem.
|
In my case, before update the ionic libraries of my project, my app was working fine (ionic v4) and I was able to subscribe to platform.basckButton, but after update to the lastest version, this sibscription stop working |
Yep same here @libattistella |
With these versions, my application is working again and I have successfully subscribed to the backButton. I hope it helps |
this.platform.backButton.subscribe() doesn't even work for me, I am using ionic 4.6.2 |
Update to 4.7.1 or later. Regards |
Confirming that it doesn't work on 4.10.0 |
any fix for this issue? |
@moh4sa - I never got a work around for it, I had to disable some of my app functionality for Android. I haven't tried Ionic 5 yet as I can't use v5 as it is broken for Windows (Tabs) - which I have to support as well. |
In my case, I implemented the "exitApp" after the subscription in the It works when you go between pages, but it does not reach the event if it is the first time you open the application, it closes it for me at once. It's Ionic 5. :/ |
Hi everyone, As of Ionic Framework v5.1.0 most of the outstanding hardware back button issues have been resolved, including the issue noted in the original post. As a result, I am going to close this issue. To better support the hardware back button integration in Ionic Framework, we launched a dedicated Hardware Back Button Documentation Page that I recommend taking a look at. If you are still running into issues with the hardware back button on the latest version of Ionic Framework, please create a new issue and include a code reproduction. Thank you! |
Bug Report
Ionic version:
[x] 4.x
Current behavior:
I have an Ionic 4 application where I have a service where I intercept the Angular routers NavigationStart events as follows..
I want to do this as I have an application wide side menu with shortcuts to each of my feature pages. If a user goes to a feature page from this menu, then I want the back button to then goto the Home page, and NOT the previous feature page where it may have navigated from.
I do this my keeping track of each route forward, and then in the handlePageRouting I have the following code
This all seems to work fine, however, I find that as soon (or soon after) I have had an instance where the above code executes the
this.router.navigateByUrl(Constants.vals.pageRoutePaths.home)
, the Android hardware button stops working. If I go to another feature page from the home page, the hardware back button does nothing. It does not cause aNavigationStart
event, nor is the following subscription called when on my home page.However, the toolbar back button does still work, it is only the hardware buttons that stops working, and never recovers until I exit the app, and restart.
Expected behavior:
I would like the hardware button to keep working after I have had to intercept and do the redirect to the Home page
Steps to reproduce:
Run the sample application on an Android device
From the Home page, first show the hardware back button works by using a button to go to either feature 1 or feature 2, and then the back button returns to Home page.
Even if we go to feature1, and then feature 2 via the button on feature 1, the hardware back button will return down the stack as expected. Also, back button from home will exit the app due to the Home page subscription
this.platform.backButton.subscribe()
.Now, to recreate the issue, go to feature1 via the Home page button, but now drag the side menu open, and goto feature 2.
Use hardware backbutton, and the
this.router.navigateByUrl('/home');
inAppRoutingService
will return us to the Home page (as we want).From now on, the hardware back button will not work. We will not see
console.log('handlePageRouting');
being logged any moreRelated code:
A sample application via GitHub
Sample app to demonstrate this is at https://github.com/pjc2007/backbuttonprob.git
-->
Other information:
Reported this exact thing on Stack Overflow
https://stackoverflow.com/questions/56112539/ionic-4-android-hardware-back-button-stops-working-after-intercepting-navigation
Ionic info:
Ionic:
The text was updated successfully, but these errors were encountered: