Ionic native deeplinking


#1

Managed to install and setup the native deeplinking module for Ionic.

App loads up fine even in cold state, where it is fully shutdown.

However, my route doesn’t take me to the correct page. It just displays the last page the app was one, or the main page if it starts the application from cold state.

app.component.ts

...
import { Deeplinks } from '@ionic-native/deeplinks';
import { Detail1Page } from '../pages/layout/app1/detail1/detail1';
...
constructor(private deeplinks: Deeplinks.........
...
this.platform.ready().then(() => {
this.splashScreen.hide();
this.deeplinks.route({
  '/item/:itemId': Detail1Page
}).subscribe((match) => {
    console.log('Successfully matched route', JSON.stringify(match));
  }, (nomatch) => {
    console.error('Got a deeplink that didn\'t match', JSON.stringify(nomatch));
  });
}
...

The console log shows:

Successfully matched route {"$args":{"itemId":"9"},"$link":{"path":"/item/9","queryString":"","fragment":"","host":"my.app.com","url":"https://my.app.com/item/9","scheme":"https"}}

app.module.ts

...
import { Deeplinks } from '@ionic-native/deeplinks';
...
providers: [
    Deeplinks,
...

detail1.ts

...
this.itemId = this.navParams.get('itemId');
...

Your help is greatly appreciated - been working on this the whole day :slight_smile:


#2

Hi, what if you add this:

IonicModule.forRoot(MyApp,
    {
      links: [
        { component: ItemPage, name: 'item', segment: 'item/:itemId' }
]
}),