So, I've implemented FirebaseDynamicLinks
like this:
val link = "https://test/?promo=$uId"
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(link))
.setDomainUriPrefix("test.page.link")
.setAndroidParameters(
DynamicLink.AndroidParameters.Builder("test")
.setMinimumVersion(1)
.build())
.buildShortDynamicLink()
.addOnSuccessListener { shortDynamicLink ->
val mInvitationUrl = shortDynamicLink.shortLink.toString()
log("test1 success $mInvitationUrl")
//shareIntent(mInvitationUrl)
}
.addOnFailureListener {
log("test1 fail")
it.printStackTrace()
}
but calling .buildShortDynamicLink()
throws me an exception:
W: com.google.android.gms.common.api.ApiException: 400: Long link is not parsable: test.page.link/generatedLongLink [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters]
and what's interesting: inserting test.page.link/generatedLongLink
in browser works as intended - on android it directs me on google play page and on pc it directs me on web site that I specified in firebase consile when I was creating dynamic link
so what's the problem with calling .buildShortDynamicLink()
and how can I fix it?
I tried this code for you
val uId = 1234241
val link = "https://www.test.com/$uId"
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(link))
.setDomainUriPrefix("https://example.page.link")
.setAndroidParameters(
DynamicLink.AndroidParameters.Builder("test")
.setMinimumVersion(1)
.build())
.buildShortDynamicLink()
.addOnSuccessListener { shortDynamicLink ->
val mInvitationUrl = shortDynamicLink.shortLink.toString()
Log.d("AAA","test1 success $mInvitationUrl")
//shareIntent(mInvitationUrl)
}
.addOnFailureListener {
Log.d("AAA", "test1 fail")
it.printStackTrace()
}
and it works fine.
If instead I didn't put "https://" on my dynamic link, I get your error.
So change
.setDomainUriPrefix("test.page.link")
with
.setDomainUriPrefix("https://test.page.link")
And all should work fine:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With