Deeplinks gives empty path

南笙酒味 提交于 2019-12-23 21:17:15

问题


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 :

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:


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" />.



来源:https://stackoverflow.com/questions/51878423/deeplinks-gives-empty-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!