Ionic 3本机深层链接

RSK*_*RSK 5 deep-linking ionic-framework ionic3 angular

设法安装和设置Ionic的本机深层链接模块。

即使在完全关闭的寒冷状态下,应用程序也可以正常加载。

但是,我的路线无法将我带到正确的页面。它仅显示应用程序所在的最后一页,如果它从冷状态启动应用程序,则显示主页。

app.component.ts

...
import { Deeplinks } from '@ionic-native/deeplinks';
import { Detail1Page } from '../pages/layout/app1/detail1/detail1';
...
constructor(private deeplinks: Deeplinks.........
...
this.platform.ready().then(() => {
this.splashScreen.hide();
this.deeplinks.route({
  '/item/:itemId': Detail1Page
}).subscribe((match) => {
    console.log('Successfully matched route', JSON.stringify(match));
  }, (nomatch) => {
    console.error('Got a deeplink that didn\'t match', JSON.stringify(nomatch));
  });
}
...
Run Code Online (Sandbox Code Playgroud)

控制台日志显示:

Successfully matched route {"$args":{"itemId":"9"},"$link":{"path":"/item/9","queryString":"","fragment":"","host":"my.app.com","url":"https://my.app.com/item/9","scheme":"https"}}
Run Code Online (Sandbox Code Playgroud)

app.module.ts

...
import { Deeplinks } from '@ionic-native/deeplinks';
...
providers: [
    Deeplinks,
...
Run Code Online (Sandbox Code Playgroud)

detail1.ts

...
this.itemId = this.navParams.get('itemId');
...
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助-整天都在努力:)

小智 2

我昨天就遇到了同样的问题...

就我而言,我没有在我的 app.module 中您应该注册的所有地方注册我的页面。

@NgModule({
  declarations: [
    MyPage
  ],
  imports: [
    IonicPageModule.forChild(MyPage)
  ],
  entryComponents: [
    MyPage
  ]
})
export class MyPageModule {}
Run Code Online (Sandbox Code Playgroud)

对我来说,我缺少IonicPageModule.forChild参考。这是文档页面,其中讨论了设置深度链接的页面。 https://ionicframework.com/docs/api/navigation/IonicPage/#usage