Deeplinks gives empty path

2019-07-20 01:46发布

I have a problem of implementing DeepLinks. I can open the app from the URL like myapp://myapp.com/route. But it doesn’t handle path of it. It just opens the program.

I open it with :

 this.deeplinks.route({
  '/route': RoutePage
    }).subscribe(match => {
  // match.$route - the route we matched, which is the matched entry from the arguments to route()
  // match.$args - the args passed in the link
  // match.$link - the full link data
  console.log('Successfully matched route', match);
}, nomatch => {
  // nomatch.$link - the full link data
  console.error('Got a deeplink that didn\'t match', nomatch);
});

But im not receiving any console logs and the path is empty, just the following message :

enter image description here

My config.xml

 <plugin name="ionic-plugin-deeplinks" spec="^1.0.17">
    <variable name="URL_SCHEME" value="iskibris" />
    <variable name="DEEPLINK_SCHEME" value="https" />
    <variable name="DEEPLINK_HOST" value="iskibris.com" />
    <variable name="ANDROID_PATH_PREFIX" value="/" />
    <variable name="ANDROID_2_PATH_PREFIX" value="/" />
    <variable name="ANDROID_3_PATH_PREFIX" value="/" />
    <variable name="ANDROID_4_PATH_PREFIX" value="/" />
    <variable name="ANDROID_5_PATH_PREFIX" value="/" />
    <variable name="DEEPLINK_2_SCHEME" value="" />
    <variable name="DEEPLINK_2_HOST" value="" />
    <variable name="DEEPLINK_3_SCHEME" value="" />
    <variable name="DEEPLINK_3_HOST" value="" />
    <variable name="DEEPLINK_4_SCHEME" value="" />
    <variable name="DEEPLINK_4_HOST" value="" />
    <variable name="DEEPLINK_5_SCHEME" value="" />
    <variable name="DEEPLINK_5_HOST" value="" />
</plugin>

Link of calling the app iskibris://iskibris.com/route Could someone help me?

1条回答
别忘想泡老子
2楼-- · 2019-07-20 02:08

Ionic Deeplinks has two methods to open another page.

  1. route
  2. routeWithNavController

When using route method you should use nav.push to navigate another page. You can implement it in your app.component.ts as below.

  @ViewChild(Nav) nav:Nav;
  constructor(private deeplinks: Deeplinks) {
    platform.ready().then(() => {

       this.deeplinks.route({
         '/about': AboutPage
       }).subscribe(match => {
         this.nav.push(AboutPage);
       }, nomatch => {
         console.error('Got a deeplink that didn\'t match', nomatch);
      });

    });
  }
}

Or else use routeWithNavController that takes a reference to a NavController and handles the actual navigation. routeWithNavController method can be implemented as below inside your app.component.ts

      @ViewChild(Nav) nav:Nav;

      constructor(private deeplinks: Deeplinks) {

        platform.ready().then(() => {

         this.deeplinks.routeWithNavController(this.nav, {
            '/about': AboutPage

          }).subscribe(match => {

            console.log('Successfully matched route', JSON.stringify(match, null, 2));
          }, nomatch => {

            console.error('Got a deeplink that didn\'t match', nomatch);
          });
        });  
 }

And one thing, In your config.xml , <variable name="URL_SCHEME" value="iskibris" /> should be changed to <variable name="URL_SCHEME" value="myapp" />.

查看更多
登录 后发表回答