深度链接给出了空路径 [英] Deeplinks gives empty path
问题描述
我在实现DeepLinks时遇到问题.我可以通过myapp://myapp.com/route之类的URL打开该应用程序.但是它无法处理它的路径.它只是打开程序.
I have a problem of implementing DeepLinks. I can open the app from the URL like myapp://myapp.com/route. But it doesn’t handle path of it. It just opens the program.
我用:
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);
});
但是我没有收到任何控制台日志,并且路径为空,仅显示以下消息:
But im not receiving any console logs and the path is empty, just the following message :
我的config.xml
My config.xml
<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 有人可以帮我吗?
Link of calling the app iskibris://iskibris.com/route Could someone help me?
推荐答案
Ionic Deeplinks
有两种方法可以打开另一个页面.
Ionic Deeplinks
has two methods to open another page.
- 路线
- routeWithNavController
使用route
方法时,应使用nav.push导航另一个页面.您可以在app.component.ts
中实现它,如下所示.
When using route
method you should use nav.push to navigate another page. You can implement it in your app.component.ts
as below.
@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
并处理实际的导航. routeWithNavController
方法可以在app.component.ts
Or else use routeWithNavController
that takes a reference to a NavController
and handles the actual navigation. routeWithNavController
method can be implemented as below inside your app.component.ts
@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" />
.
And one thing,
In your config.xml ,
<variable name="URL_SCHEME" value="iskibris" />
should be changed to
<variable name="URL_SCHEME" value="myapp" />
.
这篇关于深度链接给出了空路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!