this.platform.registerBackButtonAction doesn’t work until we tap on screen

Hi,

registerBackButtonAction function is not working until i tap on screen once. I opened ionic app and press android back button then registerBackButtonAction doesn’t work but when i tap on screen and press android back button then registerBackButtonAction is working fine. Any idea why this is happening?

Very hard to say anything without seeing any code, but I’ll throw $5 on “forgetting to wait until the platform is ready before trying to interact with it”.

I have the same problem and the code is simple, first line of app.component.ts inside the constructor

    platform.registerBackButtonAction(() => {
      alert('back');
    });

HI, did you find a solution?

I’ve been struggling with the same issue for a few hours and i found out that this is an issue with cordova splashscreen plugin.

The whole description and discussion is here: [Android 9 - target SDK 28] Backbutton not working · Issue #186 · apache/cordova-plugin-splashscreen · GitHub

Thread also contains the code of the fix and a forked repo with the fix. I switched to forked repo and this fixed the issue for me. The official cordova plugin doesn’t yet contain the fix.