Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation component seems just working with short dynamic link (firebase)

Navigation component seems just working with short dynamic link

Example: Long Dynamic Link

https://domaindebug.page.link/?link=https://www.website.com&apn=com.x.debug&isi=122...6&ibi=com.ios.x.debug&efr=1

Short Dynamic Link

https://domaindebug.page.link/register
<fragment
        android:id="@+id/fragment_register"
        android:name="com.x.presentation.feature.identification.view.RegisterFragment"
        tools:layout="@layout/fragment_register">
        <action
            ... />
        <argument
            android:name="code"
            android:defaultValue="@null"
            app:argType="string"
            app:nullable="true" />
        <deepLink
            android:id="@+id/deepLink"
            app:uri="https://domaindebug.page.link/register?code={code}" />
</fragment>

If I click on long dynamic link, nothing happens. How can I manage this? I also can't find any documentation about integrate firebase dynamic deeplink + navigation component

like image 835
rafaelasguerra Avatar asked Sep 10 '19 09:09

rafaelasguerra


1 Answers

I have not seen any official integration of dynamic links with the navigation component so far. But it's pretty simple to integrate them manually by fetching the link with help of FirebaseDynamicLinks and passing it to the NavController:

FirebaseDynamicLinks.getInstance()
            .getDynamicLink(intent)
            .addOnSuccessListener(this) { link ->
                findNavController(R.id.nav_host_fragment).handleDeepLink(Intent().apply {
                    data = link?.link
                })
            }

Please check out the sample project I've created to show the idea. It handles deep links in a separate activity to make UI smoother, but hands over the link to the navigation component for handling.

like image 53
esentsov Avatar answered Nov 05 '22 13:11

esentsov