Closed olivermuc closed 5 years ago
Do you have project files that you could attach, so it's easier to recreate?
I'm in-midst of a larger project, unfortunately due to NDA I can't post any code. But the above is generic, ie. I would expect this behavior in any ionic Android app that deals with camera usage. Btw this was already an issue with v3 for which I created a workaround by hijacking the back-button handling. This however is not possible anymore due to the nature of back-button event subscription (vs exclusively 'owning' the handling).
This is the culprit imho:
Edit: The above is triggered regardless of when and where the backbutton was pressed
Well if you could take your app, and remove everything but the bare bones then it would probably go a long way in getting this solved quicker. You have provided very good steps on how to recreate the bug, but someone is still going to have to spend time recreating the bug. If you do have the ability to provide a small project with the flow already implemented then that would be greatly appreciated.
https://github.com/olivermuc/android-hw-back-button-test
Here you go @bryce13950
Plain vanilla template app + bar code scanner plugin.
Tested it locally and it behaves the same way.
EDIT: Just to reiterate, ionic v3 still has the same issue. The difference being, that with v3 you can take full control of the hardware back button handling, not with v4, due to the code I pointed out above.
Just food for thought: What if we protected the goBack()
call by a controller variable:
goBack(animated?: boolean) {
if (this.disableAndroidBackButton) {
this.setDirection('back', animated);
return this.location.back();
} else {
return null;
}
}
This relates to: https://github.com/ionic-team/ionic/blob/e8e71838b34be3bcbb63a944ec12ce1f6e14e07e/angular/src/providers/nav-controller.ts#L64
Thanks for the suggestion we will definitely think about it. It seems like it could be a good solution, but we are going to mull it over, and get back to you.
@bryce13950 any updates? It's been 22 days and even a temporary workaround such as manually disabling the platform.backButton.subscribeWithPriority(..)
routine would help.
Otherwise camera usage is significantly impacted. Thx.
I don't think it has been discussed yet. :/
Hi @olivermuc and @bryce13950, I am investigating this issue and am not able to reproduce it on the latest Ionic (4.0.1) and Ionic Native (5.0). Clicking the back button on Android while the camera plugin is open leaves me at the page I expect when it closes the native view. Would you mind checking again on the latest and let us know? Or if I'm missing something here?
Thanks
@elylucas If you have tested this on the example project that @olivermuc created, and it is working properly, then it is probably working fine now.
Hi there,
I have tested the example project on Ionic 4.3.0, and tapping the back button leaves the camera view and brings me back to the page I was on before.
I am going to close this issue as it looks like the problem has been resolved. If you are running into any new back button issues, feel free to open a new bug report.
Thanks!
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Bug Report
Ionic Info
Describe the Bug Exiting the device's camera feature (made available via cordova plugin) via the hardware back button, results in both closing the camera & popping the nav history stack. However, the router should disregard the back button in case of camera exit.
Steps to Reproduce
Expected Behavior Cancelling the camera on Android should not interfere with app nav/routing.
Additional Context Suggestion: Perhaps add a nav/router option to temporarily suppress 'can-go-back' via hardward button.