Ionic 3:从 PlayStore 链接中获取价值 [英] Ionic 3: Getting value from PlayStore link

查看:50
本文介绍了Ionic 3:从 PlayStore 链接中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Ionic 3 应用程序,我想根据 Playstore 的下载链接在其中设置一些变量.例如,http://linktoplaystore.com/app?account=4 会将我的应用程序中的帐户变量设置为 4.有什么方法可以实现吗?

I have an Ionic 3 app and I want to set some variable inside it based on the download link from Playstore. For example, http://linktoplaystore.com/app?account=4 would set the account variable inside my app to be 4. Is there any way to achieve this?

推荐答案

我终于设法使用 Firebase 动态链接使其工作.

I finally managed to make it work using Firebase Dynamic Links.

在 Firebase 控制台中设置我的应用后,我手动创建了一个如下所示的链接:

After I've setup my app in the Firebase console, I manually created a link which looks like this:

https://myapp.page.link/?link=https://play.google.com/store/apps/details?id=com.ionicframework.myapp?account4

在我的 Ionic 应用中,我安装并配置了 Firebase 动态链接 插件:https://ionicframework.com/docs/native/firebase-dynamic-links/

In my Ionic app, I've installed and configured Firebase Dynamic Links plugin: https://ionicframework.com/docs/native/firebase-dynamic-links/

然后,在app.component.ts里面,平台初始化完成后,我使用这段代码:

Then, inside app.component.ts, after the platform is initialized, I use this code:

firebaseDynamicLinks.onDynamicLink().subscribe((res: any) => {
 let link = res;
}, err => {
  alert(err);
});

链接将是一个如下所示的 JavaScript 对象:

The link will be a JavaScript object that looks like this:

{"deepLink":"https://play.google.com/store/apps/details?id=com.ionicframework.couriermanagerclient1234?account4","clickTimestamp":1535449992657,"minimumAppVersion":0}

从这里,我可以解析结果并从 deepLink 属性中提取帐户参数

From here, I can parse the result and extract the account parameter from inside the deepLink property

这篇关于Ionic 3:从 PlayStore 链接中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆