ionic-framework: bug: hardwareBackButton config option not working as expected
Bug Report
Ionic version: [x] 4.x
Current behavior: ‘hardwareBackButton’ option described here is not working.
Expected behavior: Android hardware back button must be disabled.
Related code:
@NgModule({
declarations: [
AppComponent,
],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot({
hardwareBackButton: false,
}),
AppRoutingModule,
],
providers: [
SplashScreen,
StatusBar,
{provide: RouteReuseStrategy, useClass: IonicRouteStrategy},
],
bootstrap: [AppComponent],
})
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.12.0 (/Users/ramon.carreras/.nvm/versions/node/v8.15.1/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.4.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 6 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/ramon.carreras/Library/Android/sdk)
ios-deploy : 2.0.0
NodeJS : v8.15.1 (/Users/ramon.carreras/.nvm/versions/node/v8.15.1/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 19 (3 by maintainers)
Commits related to this issue
- fix(android): setting hardwareBackButton: false in config now disabled default webview behavior (#22555) resolves #18237 — committed to ionic-team/ionic-framework by liamdebeasi 4 years ago
Can you try the following dev build and let me know if it resolves the issue?
Angular
React
Vue
Stencil/Vanilla JavaScript
@fernandomeridamatilla @rrath-edr @fer-fullstackdev
An actual workaround that seems to work for me on @ionic/angular 4.6.2 is :
document.addEventListener("backbutton",function(e) { console.log("disabled") }, false);Code taken from cordova docs : here
Seems to work on any page other than my initial first page.
any news of this issue?
Ionic 5 / angular 9 or 10 this solution worked for me
hello, i tried workaruound too and its not workings 😦