[英]How to open an android app using a deeplink that contains a token?
I'm generation an android application from an ionic application, and i want to open it when i click on a registration link that contains a token ( http://localhost:8100/signup/token) using deeplinks.我正在从 ionic 应用程序生成 android 应用程序,当我单击包含令牌(http://localhost:8100/signup/token)的注册链接时,我想打开它。 How can i do that and how to pass the token parameter?我该怎么做以及如何传递令牌参数?
Basically you want this plugin: https://github.com/ionic-team/ionic-plugin-deeplinks基本上你想要这个插件: https://github.com/ionic-team/ionic-plugin-deeplinks
It's all explained in the Github page, but let's see:这一切都在 Github 页面中进行了解释,但让我们看看:
1 - Install the plugin: 1 - 安装插件:
cordova plugin add ionic-plugin-deeplinks
--variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=example.com
--variable ANDROID_PATH_PREFIX=/
With the DEEPLINK_SCHEME + URL_SCHEME parameters you set the domain that detects links and takes the user to your app.使用 DEEPLINK_SCHEME + URL_SCHEME 参数,您可以设置检测链接并将用户带到您的应用程序的域。 In the example above:在上面的例子中:
https://myapp https://myapp
But this is a native functionality that you can only test on a device, not with ionic serve.但这是一项本机功能,您只能在设备上进行测试,而不能使用 ionic serve。
2 - Then in your app.component.ts: 2 - 然后在你的 app.component.ts 中:
this.platform.ready().then(() => {
this.deeplinks.route({
'/about-us': HomePage,
'/products/:productId': HelpPage
}).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);
});
});
To get your parameter, use a route like 'signup/:token', and you can get that parameter ('argument') in match.$args, as you can see above.要获取您的参数,请使用“signup/:token”之类的路由,您可以在 match.$args 中获取该参数(“argument”),如上所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.