Ionic 3:从 PlayStore 链接中获取价值

Ionic 3: Getting value from PlayStore link(Ionic 3:从 PlayStore 链接中获取价值)
本文介绍了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 链接中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)