我已经定制了深度链接,对于拥有该应用程序的用户来说它运行良好。但对于没有该应用的用户,它不会将他们重定向到 Playstore。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="abc.in"
android:pathPrefix="/abc"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
我的用于生成深度链接的代码
public void Share() {
firebaseAnalyticsUtil.fireEvent("shared_link");
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT,"Hey!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Share Text - "+"http://abc.in/abc/"+ID);
startActivity(Intent.createChooser(sharingIntent,"Share using"));
}
如果用户没有该应用,请帮助我将用户重定向到 Playstore
最佳答案
您正在使用App Links ,这意味着这些是常规的 http://
链接。当您的用户点击 http://abc.in/abc
时,将会发生以下两种情况之一:
- 如果您的应用已安装,用户将可以选择打开它(要将它们直接发送到那里而不显示选择器,您需要Request App Links Verification)。
- 如果您的所有内容均未安装,用户将在网络浏览器中访问
http://abc.in/abc
。
您正在尝试处理第二种情况,方法很简单:使用 http://abc.in/abc
页面将您的访问者重定向到 Play 商店。这可以通过 Javascript 或 HTTP 来完成(307 重定向是最常见的)。
但是,请注意,仅此还不足以构成完整的深度链接解决方案。您还需要支持...
- A custom URI scheme适用于应用链接不起作用的情况。
- Chrome Intents适用于 Chrome。
- Deferred deep linking确保您的用户在下载应用后仍被发送到应用中的正确位置。
我建议研究托管深层链接服务,例如 Branch.io (全面披露:我是 Branch 团队的成员)或 Firebase 动态链接。它们将使您的生活变得更加轻松。
关于java - Android 深层链接未重定向到 Play 商店,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45005943/