管理为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));
});
}
...
控制台日志显示:
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"}}
app.module.ts
...
import { Deeplinks } from '@ionic-native/deeplinks';
...
providers: [
Deeplinks,
...
detail1.ts
...
this.itemId = this.navParams.get('itemId');
...
非常感谢您的帮助 – 一整天都在努力:)
最佳答案 我昨天遇到了同样的问题……
在我的情况下,我没有在我的app.module中的任何地方注册我的页面.
@NgModule({
declarations: [
MyPage
],
imports: [
IonicPageModule.forChild(MyPage)
],
entryComponents: [
MyPage
]
})
export class MyPageModule {}
对我来说,我错过了IonicPageModule.forChild参考.
这是文档页面,其中讨论了为深层链接设置页面的问题.
https://ionicframework.com/docs/api/navigation/IonicPage/#usage