动态链接似乎无法在安装过程中生存
我的 MainActivity 通过这种方式管理深层链接
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
intent?.let {
checkDynamicLink(intent)
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
checkDynamicLink(intent)
}
private fun checkDynamicLink(intent: Intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(this) { dynamicLink ->
dynamicLink?.link?.let { deepLink ->
viewModel.postDeepLink(deepLink)
}
}
}
viewModel
是共享的;用户登录后,主页片段将获取深层链接并由 NavController 处理它。
它在调试时以及通过 Android Studio 安装应用程序的生产版本(缩小或未缩小)时都能完美运行。当我通过 Play 商店安装生产应用程序时,会出现此问题。 打开动态链接时,将打开 Play 商店;我安装该应用程序,然后单击“继续”(事实上我看到“继续”而不是“打开”应该意味着它识别出存在打开应用程序的动态链接)。 我打开应用程序,然后登录;当它到达主片段时,显然没有需要管理的深层链接。它应该打开一个片段,但事实并非如此。
更奇怪的是:如果我通过动态链接安装应用程序,然后通过启动器(而不是游戏商店上的“继续”按钮)打开它,则动态链接和深层链接将得到正确管理。
这似乎是 Play 商店的一个错误。我的问题是,有什么我忘记了吗?
以下是清单中活动的意图过滤器:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="@string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="https" />
<data
android:host="@string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="http" />
</intent-filter>
My MainActivity manages the deep link this way
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
intent?.let {
checkDynamicLink(intent)
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
checkDynamicLink(intent)
}
private fun checkDynamicLink(intent: Intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(this) { dynamicLink ->
dynamicLink?.link?.let { deepLink ->
viewModel.postDeepLink(deepLink)
}
}
}
The viewModel
is shared; once the user is logged in, the home fragment takes the deep link and the NavController
handles it.
It works perfectly when debugging and also when installing the production version of the app through Android Studio (minified or not). The problem occurs when I install the production app through the play store.
When opening the dynamic link the Play Store is opened; I install the app and then click on "Continue" (the fact I see "Continue" rather than "Open" should mean it recognizes there's a dynamic link with which opening the app).
I open the app, then log in; when it arrives to the home fragment, apparently, there's no deep link to be managed. It should open a fragment, but it doesn't.
More strange: if I install the app through the dynamic link and then I open it through the launcher (rather than the "Continue" button on the play store) the dynamic link and the deep link are correctly managed.
It seems to be a Play Store bug. My question is, is there something I'm forgetting?
The following is the activity's intent-filter in the manifest:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="@string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="https" />
<data
android:host="@string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="http" />
</intent-filter>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 firebase 动态链接文档,有多种设置动态链接的方法。
我建议您检查动态链接上的包名称是否设置为与生产应用程序的包名称匹配。
looking at firebase dynamic links documentation, there is several ways to setupa dynamic link.
I would recommend you check that the package name on the dynamic link is set to match the package name of your production app.
该问题与 AndroidManifest 以及 Activity 的声明方式有关:
nav_graph
标签导致动态链接由应用自动管理,因此当应用通过 Play 商店启动时,动态链接的深层链接会自动管理,但用户尚未登录,因此该片段没有显示(所以它显然没有被管理)。The problem was related to the AndroidManifest and how the activity was declared:
The
nav_graph
tag caused the dynamic link to be automatically managed by the app, so when the app was launched through the play store the dynamic link's deep link was automatically managed, but the user wasn't logged in so the fragment wasn't shown (so it wasn't apparently not managed).