1
votes

im trying to use Firebase Dynamic Links to open a screen in the app, like so:

FirebaseDynamicLinks.getInstance()
        .getDynamicLink(intent)
        .addOnSuccessListener(activity) { pendingDynamicLinkData ->
            val uri = pendingDynamicLinkData?.link
            val fragment = fragmentFromUri(uri)
            fm.replace(fragment)
        }

This however is asynchronous. So my main screen is visible for a split second and then switches to a deeplinked one.

Is there way to avoid this? Can I extract the deep link synchrously? When I'm already installed I do see the intent.data parameter, however after fresh install the data is null, and only the firebase callback works. How does it even work if the intent has null extras? Is there some network check or whatever?

Thanks

2

2 Answers

0
votes

There is no way to load the dynamic link contents synchronously (that I know of at least).

The usual solution is to show a more neutral screen (for example a blank screen, or something that says "loading" in fairly neutral theming) while resolving the dynamic link, and then transitioning to either the fragment indicated in the activity, or the actual main screen.

0
votes
 fun getDeepLink(intent: Intent): String? {
        return try {
            val task = FirebaseDynamicLinks.getInstance().getDynamicLink(intent)
            val deepLink = task.result.link?:return null
            val landingSection: String = deepLink.getQueryParameter("your_link")?:return null
            landingSection
        }catch (e:Exception){
            null
        }
    }