Android深度链接:对应用程序和Play商店使用相同的链接 [英] Android Deep linking: Use the same link for the app and the play store
问题描述
我有一个网站,使用户可以进行搜索查询.该查询可能需要一些时间(几分钟到几天)才能完成,并且我想通过发送一封带有链接的电子邮件给用户,使用户能够下载Android应用并在那里接收答案.
I have a website which enables the user to make a search query. The query might take some time to complete (minutes to days), and I would like to enable the user to download an Android app and receive the answer there, by sending an email with a link to the user.
无论用户是否安装了该应用程序,我都希望这种机制能够起作用;换句话说:
I would like this mechanism to work whether the user has the app installed or not; in other words:
- 如果用户拥有该应用程序,则应使用深度链接包含标识符参数.
- 如果用户没有,请在应用程序页面上打开Play商店(例如
https://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah
),让用户安装它,然后使用标识符参数打开应用程序.
- If the user has the app it should be opened with deep link that contains an identifier argument.
- If the user does not have it it should open the play store on the app's page (e.g.
https://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah
), let the user install it, and open the app with the identifier argument.
有没有一种方法可以形成一个带有参数的打开Android应用程序的链接,无论是否安装了该应用程序,该参数都可以正常工作?
推荐答案
此替代方法可能会起作用:
This workaround might work:
-
在服务器端,创建一个指向Google Play的重定向规则.例如,
https://www.foo.com/bar/BlahBlah
将重定向到https://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah
.
在应用程序中,将服务器端链接注册为深层链接:
<data android:scheme="https"
android:host="www.foo.com"
android:pathPrefix="/bar" />
现在,如果安装了该应用程序,则将捕获URL,并且可以解析路径以提取BlahBlah
部分.如果未安装该应用,请按链接将使用引荐网址将用户重定向到Play商店.
Now, if the app is installed, the URL will be caught and the path can be parsed to extract the BlahBlah
part. If the app isn't installed pressing the link will redirect the user to the Play store with the referring URL.
注意:
-
/bar/BlahBlah
已转换为&referrer=BlahBlah
,因为Play商店接收到URL参数,并且深层链接机制可以处理URL路径(据我所知)
/bar/BlahBlah
was converted to&referrer=BlahBlah
, because the play store receives a URL argument and the deep link mechanism works with URL paths (as far a I can tell)
这篇关于Android深度链接:对应用程序和Play商店使用相同的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!