question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: hardwareBackButton config option not working as expected

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
liamdebeasicommented, Nov 23, 2020

Can you try the following dev build and let me know if it resolves the issue?

Angular

npm install @ionic/angular@5.6.0-dev.202011232116.155f2ae

React

npm install @ionic/react@5.6.0-dev.202011232116.155f2ae @ionic/react-router@5.6.0-dev.202011232116.155f2ae

Vue

npm install @ionic/vue@5.6.0-dev.202011232116.155f2ae @ionic/vue-router@5.6.0-dev.202011232116.155f2ae

Stencil/Vanilla JavaScript

npm install @ionic/core@5.6.0-dev.202011232116.155f2ae
2reactions
jackbaylisscommented, Aug 15, 2019

@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);

image

Code taken from cordova docs : here

Seems to work on any page other than my initial first page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: hardwareBackButton config option not working ... - GitHub
Current behavior: 'hardwareBackButton' option described here is not working. Expected behavior: Android hardware back button must be disabled.
Read more >
My Hardware 'Back Button Action' is not working in Ionic 4
Try This: lastTimeBackPress = 0; timePeriodToExit = 2000; @ViewChildren(IonRouterOutlet) routerOutlets: QueryList < IonRouterOutlet > ; backButtonEvent() ...
Read more >
Hardware back button with Ionic 4 Disable
Hi everyone, How do I disable the hardware back button in android? ... Issue: bug: hardwareBackButton option in Config is not working.
Read more >
How To Fix Back Button Not Working on iPhone and Android
Restart the Device. Even Android phones with a hardware back button didn't always withstand the worst software bugs. The good news is that...
Read more >
Troubleshooting | React Navigation
Missing extensions in metro configuration​. Sometimes the error may look like this: Error: While trying to resolve module "@react-navigation/native ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found