Back button not working with tabs

I have an Ionic5/Capacitor app that uses tabs.
The first tab is the “dashboard” page.
On this page, there are links to the other tabs that I open using the function switchToPage.

I’ve tried to switch the page in many ways:

    // console.log('@@@ switchToPage', pagename);
    // this.router.navigateByUrl('tabs/' + pagename);
    // this.router.navigate(['tabs/', pagename]);
    this.navCtrl.navigateForward(['tabs/', pagename])

The problem is that changing the selected tab with this function or the standard tab buttons, the back button of the mobile doesn’t work.
None of the previous ways to change page works.

Is it possible to fix this somehow?

Thank you very much


I’ve solved in this way:

  initializeApp() {
    this.platform.ready().then(() => {
      this.platform.backButton.subscribeWithPriority(10, (processNextHandler) => {
        console.log('@@@ Back pressed -> execute handler!');
        console.log('@@ Current page: ', this.router.url );
        const pagesWithoutBack = ['/tabs/dashboard', '/howto'];
        if (pagesWithoutBack.indexOf('this.router.url') >=0) {
          console.log('Vai alla dashboard.');
        } else {
          // Navigate to back page