Ionic 4 Deeplink插件返回不匹配的错误路由 [英] Ionic 4 Deeplink plugin return false route not matched

查看:72
本文介绍了Ionic 4 Deeplink插件返回不匹配的错误路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ionic 4应用程序中实现Deeplink.启动应用程序但Deeplink插件始终返回 false ;

I am Implementing Deeplink in ionic 4 application. Application in getting launched but deeplink plugin always returns false;

app.routing.ts:

app.routing.ts:

{
    path: 'viewdiary/:id/public',    
    loadChildren: () => import('./pages/viewdiary/viewdiary.module').then( m => m.ViewdiaryPageModule)
  },

app.compoent.ts:

app.compoent.ts:

setupDeepLink(){
    this.deeplinks.route({
      '/viewdiary/:id/public': 'viewdiary/:id/public'
    }).subscribe((match)=>{
      console.log('deeplink matched', match);
      const internalPath = `${match.$route}/${match.$args['id']}/${match.$route}`;
      console.log(internalPath);
      this.zone.run(()=>{
        this.general.goToPage(internalPath);
      });
    },
    nomatch=>{
      // nomatch.$link - the full link data
      console.error("Got a deeplink that didn't match", nomatch);
    })
  };

我的公共日记页面链接为'https://www.example.com/diary/12542/public'; 似乎路由问题尝试了许多更改名称的操作,但没有任何效果.我不知道怎么了.

My Public diary Page link is 'https://www.example.com/diary/12542/public'; it looks like a routing issue tried many thing changes names but nothing works. I am clueless what going wrong.

推荐答案

弄清楚了如何在另一个答案在Stackoverflow上

Figured out how to achieve it with the help of Another Answer on Stackoverflow

import { Platform, NavController } from '@ionic/angular';

constructor(public navCtrl: NavController){}


this.deeplinks.routeWithNavController(this.nav, {
    '/viewdiary/:diary/:id/:public': 'viewdiary'
  }).subscribe((match) => {
       console.log('success' + JSON.stringify(match));
  }, (noMatch) => {          
       console.log('error' + JSON.stringify(noMatch));
  });

这篇关于Ionic 4 Deeplink插件返回不匹配的错误路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆