Issue
I have implemented deep linking for my application. And I am handling my deep links by
navController.handleDeepLink(intent)
It's working fine in normal cases.
The issue is when I have deep links like this:
https://example.com/list
It should take me to a listing page
https://example.com/list?id=SOMEID&type=SOMETYPE
This should redirect the user to the details page of the item.
But this is not happening. It always takes me to the listing screen. How can I fix this?
This is how I defined the deeplink in the nav file:
<deepLink
android:id="@+id/deeplinkList"
android:autoVerify="true"
app:uri="https://example.com/list" />
and details like this:
<fragment>
<argument
android:name="id"
app:argType="string" />
<argument
android:name="type"
app:argType="string" />
<deepLink
android:id="@+id/deeplinkDetails"
android:autoVerify="true"
app:uri="https://example.com/list?id={id}&type={type}" />
</fragment>
If I remove the deeplinkList
, deeplinkDetails
will work fine. How can I fix this issue?
Solution
Well since I couldn't get a satisfactory answer I found a sort of a hack
I changed the deeplink in navigation file to be without query params. like this:
https://example.com/list/{SOMEID}/{SOMETYPE}
instead of this:
https://example.com/list?id=SOMEID&type=SOMETYPE
and I am manipulating the deeplink the way I want before calling the
navController.handleDeepLink(intent)
like this
val uri = intent.data
intent.data = Uri.parse(
"https://example.com/list/${uri?.getQueryParameter("id")}/${uri?.getQueryParameter("id")}")
navController.handleDeepLink(intent)
Answered By - hushed_voice
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.