微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ionic 5 deeplink 无法正常工作,总是进入 nomatch 块

如何解决ionic 5 deeplink 无法正常工作,总是进入 nomatch 块

package.json,这是package.json 文件

{
  "name": "deeplink","version": "0.0.1","author": "Ionic Framework","homepage": "https://ionicframework.com/","scripts": {
    "ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
  },"private": true,"dependencies": {
    "@angular/common": "~11.2.0","@angular/core": "~11.2.0","@angular/forms": "~11.2.0","@angular/platform-browser": "~11.2.0","@angular/platform-browser-dynamic": "~11.2.0","@angular/router": "~11.2.0","@ionic-native/core": "^5.31.1","@ionic-native/deeplinks": "^5.31.1","@ionic/angular": "^5.5.2","rxjs": "~6.6.0","tslib": "^2.0.0","zone.js": "~0.10.2"
  },"devDependencies": {
    "@angular-devkit/build-angular": "~0.1102.4","@angular/cli": "~11.2.4","@angular/compiler": "~11.2.0","@angular/compiler-cli": "~11.2.0","@angular/language-service": "~11.2.0","@ionic/angular-toolkit": "^3.1.1","@types/jasmine": "~3.6.0","@types/jasminewd2": "~2.0.3","@types/node": "^12.11.1","codelyzer": "^6.0.0","cordova-android": "^9.0.0","cordova-plugin-device": "^2.0.2","cordova-plugin-ionic-keyboard": "^2.2.0","cordova-plugin-ionic-webview": "^4.2.1","cordova-plugin-splashscreen": "^5.0.2","cordova-plugin-statusbar": "^2.4.2","cordova-plugin-whitelist": "^1.3.3","ionic-plugin-deeplinks": "^1.0.22","jasmine-core": "~3.6.0","jasmine-spec-reporter": "~5.0.0","karma": "~5.2.0","karma-chrome-launcher": "~3.1.0","karma-coverage": "~2.0.3","karma-coverage-istanbul-reporter": "~3.0.2","karma-jasmine": "~4.0.0","karma-jasmine-html-reporter": "^1.5.0","protractor": "~7.0.0","ts-node": "~8.3.0","tslint": "~6.1.0","typescript": "~4.0.2"
  },"description": "An Ionic project","cordova": {
    "plugins": {
      "ionic-plugin-deeplinks": {
        "URL_SCHEME": "abc","DEEPLINK_SCHEME": "https","DEEPLINK_HOST": "mytest.com","ANDROID_PATH_PREFIX": "/"
      },"cordova-plugin-whitelist": {},"cordova-plugin-statusbar": {},"cordova-plugin-device": {},"cordova-plugin-splashscreen": {},"cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },"cordova-plugin-ionic-keyboard": {}
    },"platforms": [
      "android"
    ]
  }
}


import { Component,ViewChildren,QueryList,AfterViewInit,ngzone } from '@angular/core';
    import { Deeplinks } from '@ionic-native/deeplinks/ngx';
    import { PostsPage } from './posts/posts.page';
    // import { Component,ngzone } from '@angular/core';
    import { AlertController,IonRouterOutlet,Platform } from '@ionic/angular';
    @Component({
      selector: 'app-root',templateUrl: 'app.component.html',styleUrls: ['app.component.scss'],})
    export class AppComponent {
      constructor(
        private deeplinks: Deeplinks,private zone: ngzone,private platform: Platform,) {
        this.initializeApp();
      }
    
      initializeApp() {
        this.platform.ready().then(async () => {
          this.setupDeeplinks();
        });
      }
    
    
      setupDeeplinks() {
        try {
          this.deeplinks.route({
            '/:slug': 'posts',}).subscribe(
            match => {
              // alert("match " + localStorage.getItem("accesstoken"));
    
              // Run the navigation in the Angular zone
              this.zone.run(() => {
                alert("match " + JSON.stringify(match));
              });
            },nomatch => {
              alert("error " + JSON.stringify(nomatch.$link));
              // nomatch.$link - the full link data
            }
          );
        } catch (e) {
          alert(JSON.stringify(e));
        }
      }
    
    }

我有上面的深层链接代码,但是当我点击像 https://mytest.com/4665465 这样的 url 时它不起作用,它打开了应用程序但路由不匹配它的转到 nomatch 块,我已经关注了这个视频对于这个https://www.youtube.com/watch?v=DG7TMredeUs&t=312s,请帮忙

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。