Ionic 4 : Going back from BarcodeScanner


#1

I successfully added the phonegap barcodescanner plugin and it works though there is a difference when one presses the hardware back button between android versions. On a phone with Android 5.1.1, the back button works as expected, going to the previous page BUT on Android 8.0 it goes two pages back, as if one had pressed the back button two times.

How would I debug this to see where the problem is? Could it be the plugin? Could it be ionic? Cordova?

Ionic:

   ionic (Ionic CLI)             : 4.2.1 
   Ionic Framework               : @ionic/angular 4.0.0-beta.12
   @angular-devkit/build-angular : 0.7.5
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 6.1.5
   @ionic/angular-toolkit        : 1.0.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 6.4.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 6 other plugins)

System:

   Android SDK Tools : 25.2.2 
   ios-deploy        : 1.4.0
   ios-sim           : 3.1.1
   NodeJS            : v8.11.3  
   npm               : 6.2.0
   OS                : OS X El Capitan
   Xcode             : Xcode 8.2.1 Build version 8C1002

#2

Hi,you can try subscribe to the event

this.platform.backButton.subscribeWithPriority(1,() => {
//insert what you need
});

this also works with event.preventDefault() so it won’t go back two pages