'Dynamic link seems to not survive to the installation process
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>
Solution 1:[1]
The problem was related to the AndroidManifest and how the activity was declared:
<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>
<nav-graph android:value="@navigation/nav_graph" />
</activity>
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).
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Maha Al-Selek |