There are a few places where the back button behaves differently in an Ionic 2 app than in a native android app. This is a continuation of the discussion we had in our team meeting this morning.
Which Ionic Version? 2.0.0-beta.11
I am glad you brought this up. We've been building an app with ionic 2 for a while now, and have been conducting usability tests with a number of people; mostly university students who use android. Every single one of them (literally) is always confused about the behaviour of the back button. As far as my team is concerned, we see no advantage to the current behaviour since no one expects it.
As for the last point, if tapping the back button is supposed to close the app, then that is what it should do. Preventing it will be like stopping a desktop app from closing when a user clicks the close button. It's just confusing and even annoying to regular users. Just MHO.
I do agree that it is bad to prevent users from closing the app, but it may have some valid use cases. For example in my app, if I'm at a certain root view and I press the back button, I want to log out instead of closing the app. At least we should be able to react to the event, if not prevent it. It would be great if we could choose a backbutton behaviour when we need to and rely on the default behaviour otherwise (#7590).
As always, my advice is to follow the native paradigms as much as possible even if they do not make UX sense.
I think when you traverse through tabs it should not contribute to the overall navigation history. In other words, pressing back should not take me to the "previous" tab. Each tab page should essentially be treated as the root.
Hello @jgw96, I've an issue with the sidemenu and backbutton but not sure whether it is the same issue you're describing here, because your are talking more about the app getting closed by the backbutton.
On Android, when I have the sidemenu open, the backbutton always navigates back through the stack and only closes the app when the stack is empty.
In native apps the backbutton shall close the sidemenu.
@jabas06 Yeah, that too. I had to use the following until this is fixed.
this.platform.registerBackButtonAction(()=>{
if(this.menu.isOpen()){
this.menu.close();
}else{ ...
},1);
Can we get this issue added into a milestone please? @jgw96 @manucorporat
Note this is still relevant in RC3.
+1 to this, especially in regards to tabs history. Sidemenu closing is also a really important fix.
@jgw96 you can put the link of the commit that fix these issues?
@jgw96
In a native app with a sidemenu when you navigate to another page that is not the "home" page and then tap the back button it takes you back to the "home" page. Ionic 2 simply closes the app.
This is not something we can fix, but it should be in the developer-side. If the sidemenu setRoot() a different page, then it becomes the root page. Ionic can't make more assumptions here, if they want to navPop() to go back to Home, then they should use nav.Push() instead of nav.setRoot()
@manucorporat Sorry to grab into this closed issue.
If you use nav.push you'll get the next window with the back button, instead the menu - icon.
So the point everyone would need to do is to customize it yourself on the normal "root-pages" without having to see the back-button?
Thanks
Graphefruit
Some users have expressed the desire to be able to stop the back button from closing the app in the situation where pressing the back button should close the app. I have mixed feelings about this as its generally considered bad ux to prevent a default operating system action and can seem "spammy" to stop an app from closing.
What if an option is provided to let developer decide if they want to close the app or suspend it when back buttons is pressed? Pressing back button on Facebook and WhatsApp doesnt close the app rather it minimize the app.
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.
Most helpful comment
What if an option is provided to let developer decide if they want to close the app or suspend it when back buttons is pressed? Pressing back button on Facebook and WhatsApp doesnt close the app rather it minimize the app.