使用离子本机深层链接加载角度组件

时间:2019-10-21 15:01:39

标签: javascript typescript ionic4 deep-linking ionic-native

我一直在搜索互联网,发现a great youtube tutorial使我更接近使离子深层链接正常工作。

使用android模拟器,可以看到我当前的设置与访问应用程序内的 / match 路径时要使用的路由相匹配。

我最终将在推送通知回调函数中触发此代码,但是为了进行测试,我在initializeApp()上调用了深层链接。

我已经按照教程中的建议使用了代码笔,这可以使您更深入地了解使用仿真器时的情况。单击链接后,我可以看到一些信息,直到昨天,我一直在努力寻找一种适当地访问这些信息的方法。

codepen示例:

$("#elementId" ).focus();
$("#elementId" ).select();

我的app.component.ts设置如下:

<h1><a href="sideline://sidelineapp.io/match">Alert</a></h1>

记录控制台信息的对象如下(很抱歉,仅显示图片):

enter image description here

我可以看到已找到$ route,但是由于路径需要视图的呈现组件(例如我的app-routing.module.ts而不是Ionic页面),因此视图不呈现。找到路线后,正在加载的图形刚刚挂起,并且组件未初始化。

有人可以建议解决此问题的方法吗?我已经看到了使用角度模块(而非组件)的开发人员示例。我还有什么需要做的吗?

1 个答案:

答案 0 :(得分:0)

  • 或者,如果您使用的是Ionic,则有一种便捷的方法可以引用NavController并为您处理实际的导航:
  • this.deeplinks.routeWithNavController(this.navController, { '/about-us': AboutPage, '/products/:productId': ProductPage }).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); });
  • 您还可以从此git repo链接获取参考 https://github.com/ionic-team/ionic2-deeplinks-demo/blob/master/app/app.ts
相关问题