离子3:从PlayStore链接获取价值 [英] Ionic 3: Getting value from PlayStore link
问题描述
我有一个Ionic 3应用,我想根据Playstore的下载链接在其中设置一些变量.
例如,http://linktoplaystore.com/app?account=4
会将我的应用程序内的account变量设置为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 Dynamic Links
插件: 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
属性内部提取account参数
From here, I can parse the result and extract the account parameter from inside the deepLink
property
这篇关于离子3:从PlayStore链接获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!