代码之家  ›  专栏  ›  技术社区  ›  Manuchekhr

Deeplinks提供空路径

  •  2
  • Manuchekhr  · 技术社区  · 6 年前

    我有一个实现DeepLinks的问题。我可以从myapp://myapp.com/route这样的URL打开应用程序。但它不能处理它的路径。它只是打开程序。

    我打开它:

     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);
    });
    

    但im没有接收到任何控制台日志,并且路径为空,仅显示以下消息:

    enter image description here

     <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>
    

    调用应用程序iskibris://iskibris.com/route的链接

    1 回复  |  直到 6 年前
        1
  •  1
  •   Sudarshana Dayananda    6 年前

    Ionic Deeplinks 有两种方法打开另一页。

    1. 路线

    使用时 route 方法应使用nav.push导航另一页。你可以在你的 app.component.ts 如下所示。

      @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);
          });
    
        });
      }
    }
    

    routeWithNavController 指的是 NavController 并处理实际的导航。 路由导航控制器 应用组件

          @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);
              });
            });  
     }
    

    还有一件事, 在config.xml中, <variable name="URL_SCHEME" value="iskibris" /> 应该改成 <variable name="URL_SCHEME" value="myapp" /> .