Ionic 4 Deeplink 插件返回错误路由不匹配 [英] Ionic 4 Deeplink plugin return false route not matched
本文介绍了Ionic 4 Deeplink 插件返回错误路由不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 ionic 4 应用程序中实现 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屋!
查看全文