设法安装和设置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)
非常感谢您的帮助-整天都在努力:)