简体   繁体   English

Android中的延迟深层链接网址

[英]Deferred Deep Linking URL in Android

I want to implement deferred deep linking in my android app. 我想在我的Android应用程序中实现延迟深度链接。 My understanding is I need to provide a url and when user opens the url, it will direct user to the app or to play store if the app has not been installed. 我的理解是我需要提供一个网址,当用户打开网址时,如果尚未安装该应用,它会将用户引导至应用或玩商店。 From my research, seems Android is able to resolve deferred deep linking by default. 根据我的研究,似乎Android能够默认解析延迟深度链接。 But my question is where is the URL from? 但我的问题是URL来自哪里? Does Google have any url builder to generate it for me or do I need to have a website and write some code for the url? Google是否有任何网址构建器可以为我生成或者我是否需要拥有一个网站并为网址编写一些代码?

The url comes from any app or the user. 该网址来自任何应用或用户。 Its just a normal app in the form http://example.com/path . 它只是http://example.com/path形式的普通应用程序。 THe magic is that your manifest registers an intent filter for the http scheme and the example.com/path path, and Android will take any intent that has an ACTION_VIEW for that url to your app. 不可思议的是,您的清单会为http方案和example.com/path路径注册一个intent过滤器,而Android会将具有该URL的ACTION_VIEW的任何意图注册到您的应用程序。 If your app isn't installed, since its an http url it falls back to the browser. 如果你的应用程序没有安装,因为它的http url会回退到浏览器。 If the url happens to go or redirect to the play store, then it gets you that behavior as well. 如果url碰巧或重定向到Play商店,那么它也会让你获得这种行为。

The answers and comments so far are all referring to normal deep linking. 到目前为止,答案和评论都是指正常的深层链接。 None of them will get you deferred deep linking (ie, the ability to deep link even when the app is not installed yet and the user needs to first visit the Play Store to download it). 它们都不会让你延迟深度链接(即,即使尚未安装应用程序且用户需要首先访问Play商店下载它,也能深层链接)。

Vanilla iOS does not support deferred deep linking at all. Vanilla iOS根本不支持延迟深度链接。 Android can do it with the Android Google Play referrer , but it is unreliable and doesn't work at all from Chrome. Android可以通过Android Google Play引荐来实现 ,但它不可靠,并且根本不适用于Chrome。

To do this, you'll likely want to investigate a free third-party service like Branch.io (full disclosure: I am on the Branch team). 为此,您可能希望调查像Branch.io这样的免费第三方服务(完全披露:我在分支机构团队中)。 The Branch platform abstracts all the technical details and edge cases away, so all you need to worry about is defining a set of key/value parameters (for example: articleID: story123 ) when you create a link. Branch平台将所有技术细节和边缘情况抽象化,因此您需要担心的是在创建链接时定义一组键/值参数(例如: articleID: story123 )。 Branch makes sure those parameters are returned to you inside the app the first time it launches after the user clicks the link, whether or not the app was installed when the link was clicked. 分支确保在用户单击链接后第一次启动时,应用程序内部会返回这些参数,无论是否在单击链接时安装了应用程序。 You can then use the values to route/customize however you wish. 然后,您可以根据需要使用这些值进行路由/自定义。

Firebase Dynamic Links seems to be the official Android way to support the deferred deep link that will send user across the installation UI if needed. Firebase动态链接似乎是支持延迟深层链接的官方Android方式,如果需要,它将通过安装UI发送用户。 It also works with iOS and Web. 它也适用于iOS和Web。

You can try using this scheme(to be sent to the user): 您可以尝试使用此方案(发送给用户):

intent://details?id=X&url=Y&referrer=Z#Intent;scheme=market;action=android.intent.action.VIEW;package=com.android.vending;end";

X: Package name of the App X:应用程序的包名称

Y: Deep link scheme which should be defined in the App's manifest. Y:应在App的清单中定义的深层链接方案。 (Please refer this) Here, they have used this URL as an example: " http://www.example.com/gizmos " , therefore Y should be replaced by this URL. (请参阅此处)此处,他们使用此网址作为示例:“ http://www.example.com/gizmos ”,因此Y应替换为此网址。

Z: Can be any data which you want to pass to the App via Google Play. Z:可以是您想通过Google Play传递给应用的任何数据。 Please take note that any data which you pass should not be '&' separated because the original parameters are itself '&' separated. 请注意,您传递的任何数据都不应该“分开”,因为原始参数本身是“&”分开的。

From what I experimented, this URL is understood by the browser and it redirects you to the App based on the package name and the deep-link scheme. 根据我的实验,浏览器会理解此URL,并根据包名称和深层链接方案将您重定向到App。 Else it takes you to the Google Play. 否则它会带你进入Google Play。

PS: The Google Play makes a broadcast to the app. PS:Google Play会向应用广播。 So make sure you receive the broadcast in a receiver. 因此,请确保您在接收器中收到广播。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM