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

老子叫甜甜 提交于 2019-12-20 03:29:14

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/57868086/navigation-component-seems-just-working-with-short-dynamic-link-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!