Deeplinking's defaultHistory is not working when the app is open in the browser


#1

I don’t understand how to configure deep linking properly.
The problem appears when the app is already open in the browser.
The deep linking is configured in this way:

@IonicPage({
    name: "place",
    segment: "place/:nameSlug",
    defaultHistory: ["search"],
})

So, the page shows a back button to the search page. Search page is configured with:

@IonicPage({
    name: "search",
    segment: "search",
})

When I open the link in a new browser tab it works as expected.
But if I paste the link in the same browser tab where the app is already opened, the browser doesn’t refresh the entire page (because just the fragment is changed) and it loads the expected page. The problem is that, in this case, the back button is not shown because the nav stack is empty. Is other words the defaultHistory is not setup.

Is it a correct behavior?


#2

I’m having the same problem. Did you solve this? Only difference is that I open an app from a push notification.


#3

See: Ionic PWA Loading The Wrong First Page


#4

I can’t get it to work … Let me show you what I have. Maybe you can help me out.

This problem is only when the app is closed. For now I’m only testing on Android.

app.component.ts - Where the app listens for incoming notifications and pushes the event page with some additional data

 private onPushOpened(payload: OSNotificationPayload) {
        if (payload.additionalData.eventKey && payload.additionalData.event) {

        this.notificationOpen = true;
        this.appCtrl.getRootNav().push('EventPage', {
          id: payload.additionalData.eventKey,
          event: payload.additionalData.event,
        });
    }
  }

tabs.ts

    import { Component } from '@angular/core';
    import { IonicPage } from 'ionic-angular';

    @IonicPage({
      name: "TabsPage",
      segment: "tabs",
    })
    @Component({
      templateUrl: 'tabs.html'
    })

    export class TabsPage {

      tab1Root = 'HomePage';
      tab2Root = 'AboutPage';
      tab4Root = 'SettingsPage'

      constructor() {

      }
    }

home.ts

    @IonicPage({
      name: 'HomePage',
      segment: 'home'
    })
    @Component({
      selector: 'page-home',
      templateUrl: 'home.html'
    })

event.ts

    @IonicPage({
      name: 'EventPage',
      defaultHistory: ['HomePage'] .. tried with TabsPage also.
    })
    @Component({
      selector: 'page-event',
      templateUrl: 'event.html',
    })